I have a grid that uses a GridTemplateColumn. In the ItemDataBoundEvent I want to get access to the underlying column data, heres the markup
and the codebehind
Ive tried to use the item index method, but its always empty, in the end I had to resort to getting the value of the label. How do I gain access to the underlying data from the columns ?
<telerik:GridTemplateColumn DataField="SportingEvent" UniqueName="IsSportingEvent" HeaderText="Sporting Event ?"> |
<ItemTemplate> |
<asp:Label ID="LabelSporting" runat="server" Text='<%#Eval("SportingEvent") %>'></asp:Label> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
protected void RadGridCategories_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
GridDataItem item = e.Item as GridDataItem; |
string se = item["IsSportingEvent"].Text; |
Label lbl = item["IsSportingEvent"].FindControl("LabelSporting") as Label; |
if (lbl.Text == "False") |
{ |
lbl.Text = "No"; |
} |
if (lbl.Text == "True") |
{ |
lbl.Text = "Yes"; |
} |
} |
} |
surely string se = item["IsSportingEvent"].Text; should have worked