Hi Suneel161,
Sorry for the delay....
Try the following code...
In your DropDownList SelectedIndexChanged Event..
if you using CheckBoxList Control means...
Here ddlList --> DropDownList
chkList --> CheckBoxList
int nCount = int.Parse(ddlList.SelectedItem.ToString());
for (int ix = 0; ix < chkList.Items.Count; ix++)
{
if(ix < nCount)
{
chkList.Items[ix].Selected = true;
}
else
{
chkList.Items[ix].Selected = false;
}
}
if you using CheckBox controls in your page means with out any panel (or) other control....
int nCount = int.Parse(ddlList.SelectedItem.ToString());
int nStart = 1;
foreach(Control cnt in Page.Controls)
{
foreach(Control chcnt in cnt.Controls)
{
if(chcnt is CheckBox)
{
CheckBox chk =(CheckBox)chcnt;
chk.Checked = false;
if(nStart <= nCount)
{
chk.Checked = true;
nStart++;
}
}
}
}
Try the above coding.. If you struck means ask your doubts i will explain...
Cheers :)
Thanks,
T.Saravanan
Suneel161, if this helps please login to Mark As Answer. | Alert Moderator