.Net 3.5
Telerik 2010.3.1317.35
I have a datagrid that has defined columns, and autogenerated columns are set to false,
The dataseource is a datatable and all my databindings are set on datatextfields.
on itemdatabound i compare two of the fields ((int)maxRead and (int)maxNote) and depending on the result i set the row font to bold (to show unread posts)
but as soon as i group any of the columns i get,
"maxRead is neither a DataColumn nor a DataRelation for table GroupedTable0."
I tried adding the maxRead as a defined column in the grid but that gave the same result.
heres my code,
i get the error on the "if ((int)drw["maxRead"] != (int)drw["maxNote"
])'" row below.
protected void grCaseList_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item.DataItem is DataRowView) { DataRowView drw = (DataRowView)e.Item.DataItem; if ((int)drw["maxRead"] != (int)drw["maxNote"]) { e.Item.Font.Bold = true; } } }<telerik:RadGrid ID="grCaseList" runat="server" Skin="Windows7" AllowPaging="True" AllowSorting="True" GridLines="None" ShowGroupPanel="True" Width="100%" AutoGenerateColumns="False" onitemdatabound="grCaseList_ItemDataBound"> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Windows7"></HeaderContextMenu> <MasterTableView EnableColumnsViewState="false"> <CommandItemSettings ExportToPdfText="Export to Pdf"> </CommandItemSettings> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridHyperLinkColumn DataTextField="cs_id" DataType="System.Int32" FilterControlAltText="Filter cs_id column" HeaderText="ID" UniqueName="cs_id" DataNavigateUrlFields="caseUrl"> </telerik:GridHyperLinkColumn> <telerik:GridHyperLinkColumn DataTextField="cs_header" FilterControlAltText="Filter cs_header column" HeaderText="Rubrik" UniqueName="cs_header" DataNavigateUrlFields="caseUrl"> </telerik:GridHyperLinkColumn> <telerik:GridHyperLinkColumn DataTextField="nt_us_name" FilterControlAltText="Filter nt_us_name column" HeaderText="Senast ändrad av" UniqueName="nt_us_name"> </telerik:GridHyperLinkColumn> <telerik:GridDateTimeColumn DataField="cs_timePosted" FilterControlAltText="Filter cs_timePosted column" HeaderText="Inlagt" UniqueName="cs_timePosted" DataFormatString="{0:yy-MM-dd hh:mm}"> </telerik:GridDateTimeColumn> <telerik:GridDateTimeColumn DataField="cs_timePlanned" DataType="System.DateTime" FilterControlAltText="Filter cs_timePlanned column" HeaderText="Planerat" UniqueName="cs_timePlanned" DataFormatString="{0:yy-MM-dd hh:mm}"> </telerik:GridDateTimeColumn> <telerik:GridDateTimeColumn DataField="cs_timeClosed" FilterControlAltText="Filter cs_timeClosed column" HeaderText="Avslutat" UniqueName="cs_timeClosed" DataFormatString="{0:yy-MM-dd hh:mm}"> </telerik:GridDateTimeColumn> <telerik:GridBoundColumn DataField="cs_fromIP" FilterControlAltText="Filter cs_fromIP column" HeaderText="IP" UniqueName="cs_fromIP"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="cs_fritext" FilterControlAltText="Filter cs_fritext column" HeaderText="Fritext" UniqueName="cs_fritext"> </telerik:GridBoundColumn> <telerik:GridHyperLinkColumn DataTextField="cs_fromComputerName" FilterControlAltText="Filter cs_fromComputerName column" HeaderText="Dator" UniqueName="cs_fromComputerName"> </telerik:GridHyperLinkColumn> <telerik:GridBoundColumn DataField="st_name" FilterControlAltText="Filter st_name column" HeaderText="Status" UniqueName="st_name"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ty_name" FilterControlAltText="Filter ty_name column" HeaderText="Typ" UniqueName="ty_name"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="prio" FilterControlAltText="Filter prio column" HeaderText="Prio" UniqueName="prio"> </telerik:GridBoundColumn> <telerik:GridDateTimeColumn DataField="nt_timePosted" FilterControlAltText="Filter nt_timePosted column" HeaderText="Uppdaterad" UniqueName="nt_timePosted" DataFormatString="{0:yy-MM-dd hh:mm}"> </telerik:GridDateTimeColumn> <telerik:GridHyperLinkColumn DataTextField="cs_us_name" FilterControlAltText="Filter cs_us_name column" HeaderText="Inlagt av" UniqueName="cs_us_name"> </telerik:GridHyperLinkColumn> <telerik:GridHyperLinkColumn DataTextField="adm_ad_username" FilterControlAltText="Filter adm_ad_username column" HeaderText="Ansvarig" UniqueName="adm_ad_username"> </telerik:GridHyperLinkColumn> <telerik:GridBoundColumn DataField="maxRead" FilterControlAltText="Filter maxRead column" HeaderText="maxRead" UniqueName="maxRead" Visible="False"> </telerik:GridBoundColumn> </Columns> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn> </EditFormSettings> </MasterTableView> <ClientSettings AllowDragToGroup="True"> </ClientSettings> <FilterMenu EnableImageSprites="False"></FilterMenu> </telerik:RadGrid> Page load,
dsHelpdeskG2.caseListDataTable dtCases = null; if (((AdManager.UserInfo)Session[Common.userSession]).Status == AdManager.LoginStatus.User) { dsHelpdeskG2TableAdapters.caseListTableAdapter taCases = new dsHelpdeskG2TableAdapters.caseListTableAdapter(); dtCases = taCases.caseListUser(((AdManager.UserInfo)Session[Common.userSession]).AnstId); } grCaseList.DataSource = dtCases;
grCaseList.DataBind();