Note that there are some explanatory texts on larger screens.

plurals
  1. POselect all checkbox in nested datalists
    text
    copied!<p>I have a nested datalist structure and want to put select all checkboxes on every cathegories.</p> <p>the top checkbox works fine but dont know how to do it for per main cathegory</p> <p><img src="https://i.stack.imgur.com/hRQvF.png" alt="enter image description here"></p> <p>this works fine:</p> <pre><code> 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; } } } </code></pre> <p>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</p> <pre><code> 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; } } </code></pre> <p>what is the solution</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload