Kristen Jones
asked on
C# syntax to get value from Grid row
I have a Rad Grid with a Hyperlinkcolumn that I would like to have a conditional image displayed based on the value of another field. I am getting all kinds of errors and was hoping for some guidance.
My ASPX page is
My Code behind
My ASPX page is
<telerik:GridHyperLinkColumn AllowFiltering="False" AllowSorting="False" DataNavigateUrlFields="AUTOID" DataNavigateUrlFormatString="MCDPermitView.aspx?ID={0}" DataTextField="AUTOID" EditFormHeaderTextFormat="test {0}:" FilterControlAltText="Filter AUTOIDCOLUMN column" HeaderText=" " ImageUrl="/images/Info-Small.png" UniqueName="AUTOIDCOLUMN">
<HeaderStyle Width="30px" />
</telerik:GridHyperLinkColumn>
<telerik:GridBoundColumn DataField="GIS" Display="False" FilterControlAltText="Filter GIS column" HeaderText="GIS" ReadOnly="True" UniqueName="GIS" Visible="False">
</telerik:GridBoundColumn>
My Code behind
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem dataItem = e.Item as GridDataItem;
if (dataItem["GIS"].Text == "yes")
{
(dataItem["AUTOIDCOLUMN"].Controls[0] as Image).ImageUrl = "/images/YES.png";
}
else
{
(dataItem["AUTOIDCOLUMN"].Controls[0] as Image).ImageUrl = "/images/NO.png";
}
}
}
ASKER
Thanks for the help and code.. A copy/paste of your code I am getting a syntax error on the "if" line that dataItem does not exist in the current context
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
no one else helped so I had to figure the solution out myself
Open in new window