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

Obtain parent item value from radgrid hierarchy

2 Answers 209 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aret
Top achievements
Rank 1
Aret asked on 09 Oct 2012, 08:03 PM
I have a three level radgrid hierarchy and I have trouble retrieving the value for one of my columns within the 2nd level of my radgrid.  I have this code which retrieves the key for the radgrid parent as shown below:

parentItem.OwnerTableView.DataKeyValues(parentItem.ItemIndex)("ID").ToString


But I don't need the value of the key, instead I need the value of the 2nd column in one of the hierarchy levels in my radgrid.

How could I retrieve that value instead of the key....?

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 10 Oct 2012, 03:37 AM
Hi Aret,

Try accessing the column value as shown below.
C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "DetailTable1")
  {
    GridDataItem item = (GridDataItem)e.Item;
    string value = item["UniqueName"].ToString();
  }
}

Thanks,
Shinu.
0
Aret
Top achievements
Rank 1
answered on 10 Oct 2012, 02:35 PM
Thank You so much, you led me to the correct answer.  I just had to make one minor modification to the code you provided me with by changing .tostring() to .text as shown below:

string value = item["UniqueName"].Text;
Tags
Grid
Asked by
Aret
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Aret
Top achievements
Rank 1
Share this question
or