Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
the code worked when i created a new web form again. but when i added other codes for file
uploading it doesnt work anymore. it seems that the code does not work if add other codes in
the web form ???


for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkDelete = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("chkSelect");
if (chkDelete != null)
{

if (chkDelete.Checked)
{
strID = GridView1.Rows[i].Cells[1].Text;
idCollection.Add(strID);
}
}
}


XML
<Columns>
                       <asp:TemplateField>
                       <ItemTemplate>
              <asp:CheckBox ID="chkSelect" runat="server" />
             </ItemTemplate>

                       </asp:TemplateField>
                   </Columns>
Posted
Comments
Shahriar Iqbal Chowdhury/Galib 16-Feb-13 8:47am    
It seems you didn't post full code of gridview, Pls post your full gridview code.

1 solution

this will be helpful, try this
C#
for (int i = 0; i < GridView1.Rows.Count; i++)
{
     CheckBox chkDelete = (CheckBox)GridView1.Rows[i].FindControl("chkSelect");
     
     if (chkDelete != null)
     {
          if (chkDelete.Checked)
          {
               Label myLabel = (Label)GridView1.Rows[i].FindControl("TEXT_CONTROL_ID");
               idCollection.Add(myLabel.Text);
          }
     }
}
 
Share this answer
 
v2

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