I have added in an form in aspx page this CheckBoxList
:
<asp:CheckBoxList ID="Fruits" runat="server">
<asp:ListItem Text="Mango" Value="1" />
<asp:ListItem Text="Apple" Value="2" />
<asp:ListItem Text="Banana" Value="3" />
<asp:ListItem Text="Guava" Value="4" />
<asp:ListItem Text="Orange" Value="5" />
</asp:CheckBoxList>
In this CheckBoxList
it's possible select multiple values, e.g. :
And this values are memorized in field of database table:
for (int i = 0; i < Fruits.Items.Count; i++)
{
if (Fruits.Items[i].Selected == true)
{
FruitsUpdate += Fruits.Items[i].Text.ToString() + ";";
}
}
Value memorized in database : 1;4;5;
Now in aspx form page I need disable and checked the values of CheckBoxList
memorized in database, but I have tried this code without success because all ListItem
are disabled but not checked.
FruitsDB = dr["Fruits"].ToString();
if (FruitsDB.ToString() != "")
{
Fruits.Text = FruitsDB.ToString();
Fruits.Enabled = false;
}
else
{
Fruits.Enabled = true;
}
Please help me, thank you in advance.
Aucun commentaire:
Enregistrer un commentaire