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

Easily getting a cell from a selected row

1 Answer 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
M Fries
Top achievements
Rank 1
M Fries asked on 18 Dec 2008, 07:13 PM
We have a simple radGrid setup with needDatasource against an arraylist for a demo.

This should be super easy, but on a selectedIndexChange event we want a one line statement to grad the cell data.

We can only find this: 
        foreach (GridDataItem dataitem in RadGrid1.SelectedItems) 
        { 
            string strTxt = dataitem["Category"].Text; 
        } 


Is there not something like   RadGrid1.SelectedItems[0].dataitem["Category"].Text?   Do we really have to use the foreach loop?

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 18 Dec 2008, 07:31 PM
Hello,

Please test the following code-snippets:
Hashtable values = new Hashtable(); 
(RadGrid1.SelectedItems[0] as GridDataItem).ExtractValues(values); 
string test = values["CategoryName"].ToString(); 

or
string test2 = (RadGrid1.SelectedItems[0] as GridDataItem)["CategoryName"].Text; 

to get DataKeys
string test32 = (RadGrid1.SelectedItems[0] as GridDataItem).GetDataKeyValue("CategoryID").ToString(); 

Let us know if you need more information.

Kind regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
M Fries
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or