mercredi 11 octobre 2017

How to disable/enable checkboxlist depending upon dataset

I have three Checkboxlist where data are bound dynamically

<div class="checkboxData" id="cblStrengthId">
    <asp:CheckBoxList ID="cblStrength" Class="checkBoxFilter" runat="server"
DataTextField="language"  AutoPostBack="true"
OnSelectedIndexChanged="cblStrength_SelectedIndexChanged" 
DataValueField="language" RepeatLayout="OrderedList" Width="432px">  
    </asp:CheckBoxList> 
    </div>

<div class="checkboxData" id="cblFormId">
        <asp:CheckBoxList ID="cblForm" Class="checkBoxFilter" runat="server"
    DataTextField="language"  AutoPostBack="true"
    OnSelectedIndexChanged="cblForm_SelectedIndexChanged" 
    DataValueField="language" RepeatLayout="OrderedList" Width="432px">  
        </asp:CheckBoxList> 
        </div>

<div class="checkboxData" id="cblSizeId">
        <asp:CheckBoxList ID="cblSize" Class="checkBoxFilter" runat="server"
    DataTextField="language"  AutoPostBack="true"
    OnSelectedIndexChanged="cblSize_SelectedIndexChanged" 
    DataValueField="language" RepeatLayout="OrderedList" Width="432px">  
        </asp:CheckBoxList> 
        </div>

This is the three checkboxlist and their data is bounded by dataset values

if (dsFilterItems.Tables.Count >= 0)
        {
            cblStrength.DataSource = dsFilterItems.Tables[0];
            cblStrength.DataTextField = "Strength";
            cblStrength.DataValueField = "Strength";
            cblStrength.DataBind();

            cblForm.DataSource = dsFilterItems.Tables[1];
            cblForm.DataTextField = "itemForm";
            cblForm.DataValueField = "itemForm";
            cblForm.DataBind();

            cblSize.DataSource = dsFilterItems.Tables[2];
            cblSize.DataTextField = "CF_Size";
            cblSize.DataValueField = "CF_Size";
            cblSize.DataBind();
        }

Checkbox data is loaded depending upon the searched value which is loaded from database. After data is bounded the sample checkbox data is shown below in a image file

check here for sample loaded data

Sample if image is not clear

Strength

1.100 
2.250
3.500
4.1000

Form

1.CAP
2.TAB
3.POW
4.SOL

Size

1.10
2.30
3.50
4.100
5.300
6.100 ml
7.250 ml

If I select CAP from Form checkbox it should enable only respected strength and size all other checkbox should be disabled.




Aucun commentaire:

Enregistrer un commentaire