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

Rad Grid Cell Data

5 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jonny Sheldrake
Top achievements
Rank 1
Jonny Sheldrake asked on 07 Aug 2008, 12:42 PM
Hi All,

Can anyone help?

I need to know how i can get the data from my selected row in my grid view. I need this value to repopulate my grid view with new data.

Can this be done in the same way as the standard grid view in VS using findcontrol("Name") or selectedrows.cells[0]?

Cheers

Jonny

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 07 Aug 2008, 02:15 PM
Hello Jonny,

You can use the following code in order to obtain the cell text from the selected row:

RadGrid1.SelectedItems[0]["Column"].Text 

Additional information about how to access cells and rows in RadGrid you can gather from these sources:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/AccessingCellsAndRows/DefaultCS.aspx
http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jonny Sheldrake
Top achievements
Rank 1
answered on 08 Aug 2008, 12:01 PM
Hi Daniel,

Am i missing a trick here as the code you suggested is not valid. RadGrid1.SelectedItems[0] is ok but the ["ColumnName"].text is not an option and when i recomplie VS dosn't like it.

Any more advice? The links you sent look a bit complex for something whic should be pretty simple.

Cheers

Jonny
0
Sebastian
Telerik team
answered on 08 Aug 2008, 12:07 PM
Hello Jonny,

It seems that I missed to cast the corresponding item to GridDataItem in this case - please excuse me for that. The proper code slice should be as follows:

(RadGrid1.SelectedItems[0] as GridDataItem)["Column"].Text 

Kind regards,
Daniel,
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Princy
Top achievements
Rank 2
answered on 08 Aug 2008, 12:30 PM
Hi Jonny,

You can also try the following code snippet to access the selected item in the PreRender event of RadGrid.

CS:
protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridDataItem item in RadGrid1.SelectedItems)  
        {  
            string strTxt = item["columnUniqueName"].Text.ToString();  
        }  
         
    } 


Thanks
Princy.

0
Jonny Sheldrake
Top achievements
Rank 1
answered on 08 Aug 2008, 12:34 PM
Spot on mate thanks!!!!!!
Tags
Grid
Asked by
Jonny Sheldrake
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Jonny Sheldrake
Top achievements
Rank 1
Sebastian
Telerik team
Princy
Top achievements
Rank 2
Share this question
or