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

Refresh RadGrid after change on another RadGrid

4 Answers 166 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 05 Jan 2012, 11:18 AM
Hi,

I want to implement an interface with 2 RadGrid's with a plitter between them to give an 'Explorer' like view.  When the user clicks on a row in the left hand grid it identifies the item being clicked and will re-display the right hand grid to show details of the item selected.  I would have thought that this would be trivial but I can't seem to get it to work.

I have captured the SelectedIndexChanged event for the LH grid but when I look at the gridParts.SelectedItems[0].DataItem value it is always NULL which I am not sure why.

Any-one got an example of using 2 grids in this way?

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 05 Jan 2012, 01:36 PM
Hello Chris,

you can use DataItem only in itemDataBound Event in other event it is always null.

please You can achieve your requirement by using DataKeyNames.
<MasterTableView DataKeyNames="ID">
if (RadGrid1.SelectedItems != null && RadGrid1.SelectedItems.Count > 0)
        {
            string strId = (RadGrid1.SelectedItems[0] as GridDataItem).GetDataKeyValue("ID").ToString();
        }


Let me know if you have concern.


Thanks,
Jayesh Goyani
0
Princy
Top achievements
Rank 2
answered on 05 Jan 2012, 02:44 PM
Hello Chris,

Try the following code snippet to access the DataKeyValue from SelectedIndexChanged event.
C#:
protected void RadGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
 
 ID=  RadGrid1.SelectedItems[0].OwnerTableView.DataKeyValues[RadGrid1.SelectedItems[0].ItemIndex]["CustomerID"] ;
}

Thanks,
Princy.
0
Chris
Top achievements
Rank 1
answered on 06 Jan 2012, 05:47 PM
Thanks - works great - however does this mean that I cannot access a specific column value directly uunless the column is also set within the DataKeyNames?
0
Jayesh Goyani
Top achievements
Rank 2
answered on 07 Jan 2012, 05:11 AM
Hello Chris,
protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridDataItem item = RadGrid1.SelectedItems[0] as GridDataItem;
        string strId = item["ID"].Text;//ColumnUniqueName
    }
<telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
                      </telerik:GridBoundColumn>


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Chris
Top achievements
Rank 1
Share this question
or