views:

14607

answers:

6

Hi There, Ive no problems using Javascript to read the rows of a telerik radgrid component im using however I can seem to find anyway to access the row data server side when a postback occurs. Ive spent ages looking for solution but no luck. Any pointers would be greatly appreciated.

Tony

+3  A: 

You might want to look at the DataKeyValues property of the OwnerTableView object, which will let you access a collection of values that represent the fields in a given row. I use it during the EditCommand event handler, since a user of my site is directed to an edit page if they click on the link to edit a row in the grid, and I need to pass along certain info about the given row in the query string.

If this turns out to be what you need, you'll also need to define which fields should be made available through this property. To do that, look at the MasterTableView.DataKeyNames property in the property sheet for the grid. You basically specify a comma-delimited list of field names.

Chris Tybur
Hi Chris, Thanks a mill for that. That works no prob for items bound to the grid. Do you know how to acces textboxes added to a grid that are not bound but are used to trap any row related input a user put for that column Thanking you, Tony
TonyNeallon
So far I've only dealt with bound columns, but check out http://www.telerik.com/help/aspnet/grid/gridreferencecontrolsinroweditform.html and http://www.telerik.com/help/aspnet/grid/grdusinggetitemsgetcolumnmethods.html, they might be helpful.
Chris Tybur
A: 

Did you ever get this to work? I have been struggling with this forever and I swear you literally can't do it.

tbone
+1  A: 

The server-side is the easy part:

GridItemCollection gridRows = TestGrid.Items;
foreach (GridDataItem data in gridRows)
{
    ItemClass obj = (ItemClass)data.DataItem;
}

It's the client side part that I don't know! :[

+3  A: 

I use the Telerik grid from some time and found these articles in their docs about how to fetch data from selected rows server or client side:

Server-side Client-side

Hope you will find them helpful.

Dick

Dick Lampard
A: 
private Int32 GetID()
{
    foreach (Telerik.Web.UI.GridDataItem dataItem in radGrid.MasterTableView.Items)
    {
        if (dataItem.Selected == true)
        {
            Int32 ID = (Int32)dataItem.GetDataKeyValue("ID");
            return ID;
        }
    }
    throw new ArgumentNullException("Id Not found");
}
A: 
private Int32 GetID()
{
    foreach (Telerik.Web.UI.GridDataItem dataItem in radGrid.MasterTableView.Items)
    {
        if (dataItem.Selected == true)
        {
           // Int32 ID = (Int32)dataItem.GetDataKeyValue("ID");
Int32 ID =Convert.ToInt32(dataItem.GetDataKeyValue("ID"));
            return ID;
        }
    }

}
//this will work
Binay Rana