Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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);
}
}
}
 

<Columns>
                       <asp:TemplateField>
                       <ItemTemplate>
              <asp:CheckBox ID="chkSelect" runat="server" />
             </ItemTemplate>
 
                       </asp:TemplateField>
                   </Columns>
Posted 16-Feb-13 2:38am
Comments
Shahriar Iqbal Chowdhury/Galib at 16-Feb-13 8:47am
   
It seems you didn't post full code of gridview, Pls post your full gridview code.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

this will be helpful, try this
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);
          }
     }
}
  Permalink  
v2

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

  Print Answers RSS
0 Maciej Los 589
1 OriginalGriff 309
2 CPallini 205
3 RyanDev 165
4 Sergey Alexandrovich Kryukov 110
0 OriginalGriff 5,689
1 Sergey Alexandrovich Kryukov 4,803
2 Peter Leow 2,974
3 Maciej Los 2,819
4 DamithSL 2,465


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 16 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100