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

get selected row server side

1 Answer 431 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jomey
Top achievements
Rank 1
Jomey asked on 22 Sep 2008, 11:11 PM
On selectedindexchanged - i want to get the selected row and each column values and assign them to labels.

I can get the value of one of the column's of the selected row:        rgMain.SelectedItems[0].OwnerTableView.DataKeyValues[rgMain.SelectedItems[0].ItemIndex]["id"];

I need to get all the column values for the selected row.

Isn't there a way to get the values based on rgMain.SelectedItems[0].ItemIndex and the column names?

So if i have 3 columns: id, name, desc

I want to get the values of name and desc using the selectedrow on selectedindexchanged


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Sep 2008, 04:17 AM
Hi Jomey,

Try accessing the cell value for a selected row using the column UniqueName property as shown below.

CS:
protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        foreach (GridDataItem selectedItem in RadGrid1.SelectedItems) 
        { 
            string strName = selectedItem["Name"].Text; 
            string strID = selectedItem["ID"].Text; 
        } 
    } 


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