I have a nested datalist structure and want to put select all checkboxes on every cathegories.
the top checkbox works fine but dont know how to do it for per main cathegory
this works fine:
protected void cbTamaminiSec_CheckedChanged(object sender, EventArgs e)
{
CheckBox cbTemp;
foreach (DataListItem ItemP in parentDataList.Items)
{
cbTemp = (CheckBox)parentDataList.Items[ItemP.ItemIndex].FindControl("cbTumunuSec");
cbTemp.Checked = cbTamaminiSec.Checked;
DataList nestedDataList = (DataList)parentDataList.Items[ItemP.ItemIndex].FindControl("nestedDataList");
foreach (DataListItem Item in nestedDataList.Items)
{
cbTemp = (CheckBox)nestedDataList.Items[Item.ItemIndex].FindControl("cbTamam");
cbTemp.Checked = cbTamaminiSec.Checked;
}
}
}
but don't know about partially select (below codes for the chechboxes in the parentdatalist) I put selected id as "0" to emphasize the problem
protected void cbTumunuSec_CheckedChanged(Object sender, EventArgs e)
{
int selected = 0;//= (int)parentDataList.SelectedItem.ToString(); // problem is here..
DataList nestedDataList = (DataList)parentDataList.Items[selected].FindControl("nestedDataList");
foreach (DataListItem Item in nestedDataList.Items)
{
CheckBox cbTemp = (CheckBox)nestedDataList.Items[Item.ItemIndex].FindControl("cbTamam");
cbTemp.Checked = true;
}
}
what is the solution
problem solved! asp code:
code behind: