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

How to loop RadGrid in ItemCommand Event

2 Answers 218 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 24 Apr 2012, 10:03 AM
HI All,
I have a imagebutton in RadGRid with CommanName="Reprocess".
When user click on the imageButton it fire ItemCommand event and check if the checkbox at each row is checked. If it is check then it perform logic A else it perform logic B.

My question is it possible to loop RadGrid in ItemCommand event? Doed anyone as any idea to do this?
Help Please!!


2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Apr 2012, 10:20 AM
Hello Johnson,

Try the following code to loop through items in ItemCommand event.
C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{   
 if (e.CommandName == "Reprocess")
 {
   foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
  {
    CheckBox chk = (CheckBox)item.FindControl("CheckBox1");
    if (chk.Checked == true)
    {//perform logicA
    }
    else
    {//perform logicB
    }
  }
 }
}

Thanks,
Shinu.
0
johnson lim
Top achievements
Rank 1
answered on 25 Apr 2012, 07:42 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