Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually what i have to do,
if i select 4 people then seat booking 4 checkbox should checked , not more than that..

What I have tried:

<pre>  Repeater repeater = (Repeater)e.Item.FindControl("Repeater1");
        CheckBoxList List = (CheckBoxList)repeater.Items[0].FindControl("CheckBoxList1");
        foreach (ListItem listItem in List.Items)
        {
            if (listItem.Selected)
            {
                
            }
            else
            {
                //do something else 
            }
        }
Posted
Updated 20-Jun-18 1:20am
v2
Comments
Christopher Fernandes 20-Jun-18 6:48am    
what is there inside the repeater?
ADI@345 20-Jun-18 7:17am    
checkboxlist

1 solution

If you need to check amount of selected items, you probably need this instead of the foreach part. How many you have checked you can see in this property.
 
Share this answer
 
Comments
ADI@345 20-Jun-18 7:27am    
List<string> term = new List<string>();

foreach (RepeaterItem item in Repeater1.Items)
{
CheckBoxList CheckBoxList1 = (CheckBoxList)item.FindControl("CheckBoxList1");
foreach (ListItem item1 in CheckBoxList1.Items)
{
if (item1.Selected == true)
{

term.Add(item.ToString());
TextBox1.Text = term.Count.ToString();


}

}
ADI@345 20-Jun-18 7:27am    
Sir, i have to check checkbox based on textbox value automatically.
Zdenek Sedlak 20-Jun-18 9:50am    
What I understood from your code, when you have CheckBoxList1 assigned, you could use TextBox1.Text = CheckBoxList1.SelectedItems.Count and skip the whole foreach part.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900