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

Template Column with GridDataItem

1 Answer 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Angella
Top achievements
Rank 1
Angella asked on 18 May 2012, 01:11 PM
Hi all,

During the OnItemDataBound, I'm using the GridDataItem to retrieve values from the grid. I'm able to do this without the regular columns. The instructions for the Template column said:  For template columns you must find the control in the grid cell and extract its value.please give an example.

Following is the aspx code for the column :
 <telerik: GridTemplateColumn HeaderText="Unloading Type" UniqueName="UnloadTypeColumn">
                        <ItemTemplate>
                                     <%#DataBinder.Eval(Container.Dataitem, "_UnloadTypeName")%>
                        </ItemTemplate>
</telerik:GridTemplateColumn>

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 18 May 2012, 01:20 PM
Hello Angella,

Try accessing the value as shown below.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
 {
  GridDataItem item = (GridDataItem)e.Item;
  string s = ((DataRowView)e.Item.DataItem)["UnloadTypeName"].ToString();}
 }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Angella
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or