Click here to Skip to main content
15,914,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,

I Have insert checkbox ctrl on gridview ctrl in asp.net,

i need to select the row from gridview which checkbox is selected,


My code is:

foreach(GridViewRow row in GridView1.Rows )
{
CheckBoxList cb = (CheckBoxList )row.Cells [0].FindControl("cbl") ;
if(cb.Checked==true)
{
// this line is not executed even though i have selected the checkbox.
}

}

My Question is how to find whic checkbox is selected?


Thank U,

U.Sankar
Posted

1 solution

C#
foreach (GridViewRow row1 in GridView1.Rows)
      {
          CheckBox chk = (CheckBox)row1.FindControl("chkId");
          if (chk.Checked)
          {
              String strTem = chk.ID;
          }
      }



you can try it.
 
Share this answer
 
Comments
sankar guru 19-Nov-10 4:18am    
Hai Friend,

Thanks for your reply,
i try your code ,but i show "chk.Checked= false" even i select the checbox .
Abdul Quader Mamun 19-Nov-10 4:26am    
Yes sometime this type of problem occurred. If you use HTML checkbox or use session then this porblem mostly occurred. Try to use asp:checkbox

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