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

[Solved] multiple selected rows in an OnClick event

2 Answers 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sabarishbabu
Top achievements
Rank 1
sabarishbabu asked on 24 Jul 2009, 01:35 PM
Hi

i have created a grid with checkbox column. I would like to get the record Id for multiple selected rows in an OnClick event of a button. The button is not part of the grid.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Jul 2009, 04:37 AM
Hi Sabarishbabu,

You can loop through the selected items in order to get the id from selected rows as shown below.

C#:
 
protected void Button1_Click(object sender, EventArgs e) 
{         
    foreach(GridDataItem item in RadGrid1.SelectedItems) // Loop through each selected items 
    { 
        Response.Write(item["ID"].Text.ToString());  // Where ID is the ColumnUniqueName 
        string ID = item.GetDataKeyValue("ID"); // Works if you set the DataKeyValue as ID 
    } 

-Shinu.
0
sabarishbabu
Top achievements
Rank 1
answered on 28 Jul 2009, 06:02 AM
Hi Shinu,
 Thanks for your reply.

Thanks
Sabarish
Tags
Grid
Asked by
sabarishbabu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
sabarishbabu
Top achievements
Rank 1
Share this question
or