This is a migrated thread and some comments may be shown as answers.

Loop Grid in Grid_ItemCommand event

2 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
johnson lim
Top achievements
Rank 1
johnson lim asked on 04 Mar 2012, 03:20 PM
Hi all, i have a check box in every row of radgrid. User can then choose which record to print by checking the checkbox.They can then print by clicking a button embedded in the radgrid which has the CommandName="Print".This will fires the ItemCommand event and i want to check which checkbox has been checked and then print them out.
My question is i cannot loop through the radgrid via ItemCommand  event.
Can anyone help ?
Please!!

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Mar 2012, 05:39 AM
Hello,

Try the following code.
C#:
protected void grid_ItemCommand(object sender, GridCommandEventArgs e)
{
 if (e.CommandName == "CommandName")
 {
   foreach (GridDataItem item in grid.MasterTableView.Items)
   {
    CheckBox chk = (CheckBox)item.FindControl("CheckBox1");
   }
 }
}

-Shinu.
0
johnson lim
Top achievements
Rank 1
answered on 06 Mar 2012, 04:48 AM
Thanks Shinu !!
Tags
Grid
Asked by
johnson lim
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
johnson lim
Top achievements
Rank 1
Share this question
or