I have a RadGrid. Trying to change the font colors when an specific value is present. As an example...If Status Code != 0 then change color to red. Now I have that working fine, however when I click on any of the nested grids I get an error stating that "Status Code" isn't in the grid. I know that because It is a different grid (under the parent) for some reason it is still validating against the parent when it shouldn't. Any ideas? It works at the parent level. I don't want the sub grids to change at all, just the parent.
Here is the ASP code:
<telerik:RadGrid
runat="server"
ID="RadGrid1"
AllowPaging="true"
AllowFilteringByColumn="true"
AllowSorting="true"
PageSize="40"
AutoGenerateColumns="True"
CellSpacing="-1"
GridLines="Both"
GroupPanelPosition="Top"
DataSourceID="SqlDataSource1" OnItemDataBound="grd_RowDataBound">
<MasterTableView
EnableHeaderContextMenu="true"
OnPreRender="Grid1_PreRender"
DataKeyNames="trxids,TransactionType"
Name="Master" AutoGenerateColumns="true" runat="server">
<DetailTables>
<telerik:GridTableView HeaderStyle-Font-Bold="true" AlternatingItemStyle-BackColor="LightBlue"
DataSourceID="SqlDataSource2"
AllowFilteringByColumn="false"
AllowSorting="false"
DataKeyNames="trxid,TransactionType" >
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="trxids" MasterKeyField="trxids"></telerik:GridRelationFields>
<telerik:GridRelationFields DetailKeyField="TransactionType" MasterKeyField="TransactionType"></telerik:GridRelationFields>
</ParentTableRelation>
<DetailTables>
<telerik:GridTableView HeaderStyle-Font-Bold="true" ItemStyle-ForeColor="DarkRed"
DataSourceID="SqlDataSource3"
AllowFilteringByColumn="false"
AllowSorting="false" >
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="trxid" MasterKeyField="trxid"></telerik:GridRelationFields>
<telerik:GridRelationFields DetailKeyField="TransactionType" MasterKeyField="TransactionType"></telerik:GridRelationFields>
</ParentTableRelation>
</telerik:GridTableView>
</DetailTables>
</telerik:GridTableView>
</DetailTables>
</MasterTableView>
</telerik:RadGrid>
Code behind is as follows:
protected void grd_RowDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
TableCell cell = (TableCell)item["Status Code"];
if (cell.Text != "0")
{
cell.ForeColor = System.Drawing.Color.Red;
cell.Font.Bold = true;
cell.Font.Size = 8;
cell.BackColor = System.Drawing.Color.LightGray;
GridDataItem item1 = (GridDataItem)e.Item;
TableCell cell1 = (TableCell)item["count"];
cell1.ForeColor = System.Drawing.Color.Red;
cell1.Font.Bold = true;
cell1.Font.Size = 8;
cell1.BackColor = System.Drawing.Color.LightGray;
}
}
}