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

How to get Radgrid column item text on SelectedIndexChanged

4 Answers 573 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 1
JJ asked on 15 Jul 2010, 10:57 PM
I know

rg.SelectedItems[0].OwnerTableView.DataKeyValues[rgScheduleList.SelectedItems[0].ItemIndex][

"SCHEDULE_ID"]

 

 will get the value for the datakey on the grid, how about none data key item text? like name field on the grid?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Jul 2010, 07:13 AM
Hi Jessie,


You can easily achieve this by using the ColumnUniqueName.

C#:
protected void Button1_Click(object sender, EventArgs e)
{
    GridDataItem gridItem = (GridDataItem)RadGrid1.SelectedItems[0];
    string name = gridItem["CompanyName"].Text;  // Get the cell value
 
    string dataKey = gridItem.GetDataKeyValue("CustomerID").ToString(); // Get the datakeyvalue
}



-Shinu.
0
Tsvetoslav
Telerik team
answered on 16 Jul 2010, 07:50 AM
Hello Jessie,

In addition, you can use the GridDataItem object's ExtractValues() method passing to it a hash table. The latter will be populated will the key-value pairs for your columns:

protected void Button1_Click(object sender, EventArgs e)
{
    GridDataItem gridItem = (GridDataItem)RadGrid1.SelectedItems[0];
    Hashtable fieldValues = gridItem.ExtractValues(fieldValues);
   
   .....
  
}

Hope it helps.

Greetings,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
JJ
Top achievements
Rank 1
answered on 16 Jul 2010, 03:42 PM
thanks !
0
JJ
Top achievements
Rank 1
answered on 16 Jul 2010, 03:42 PM
thabk you Tsvetoslav !
Tags
Grid
Asked by
JJ
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Tsvetoslav
Telerik team
JJ
Top achievements
Rank 1
Share this question
or