checkboxlist pouplated selected values

Apr 10 2017 10:29 AM

<asp:CheckBoxList runat="server" ID="chklisttype">
<asp:ListItem Value="0"> zero</asp:ListItem>
<asp:ListItem Value="1"> one</asp:ListItem>
<asp:ListItem Value="2"> Tow</asp:ListItem>
<asp:ListItem Value="3"> three</asp:ListItem>
<asp:ListItem Value="4"> four</asp:ListItem>
</asp:CheckBoxList>


string[] Type = {0,1,3,};
string[] checkboxType = Type.Take(Type.Count() - 1).ToArray();
foreach (System.Web.UI.WebControls.ListItem lst in chklisttype.Items)
{
for (int i = 0; i <= checkboxType.Length - 1; i++)
{
if (lst.Value == checkboxType[i])
{
lst.Selected = true;

}
}

}

my checkbox list only pouplates first value only,

how to populated my checkboxlist selected values


Answers (1)