or
<telerik:RadGrid ID="RadGridSingleClick" runat="server" Skin="Vista" AutoGenerateColumns="true" OnNeedDataSource="RadGridSingleClick_NeedDataSource" OnPreRender="RadGridSingleClick_PreRender" OnUpdateCommand="RadGridSingleClick_UpdateCommand" OnColumnCreated="RadGridSingleClick_ColumnCreated" Height="250px" Width="1000px"> <%--OnItemDataBound="RadGridText_ItemDataBound" --%> <MasterTableView HeaderStyle-CssClass="disable-highlight" Width="98%" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Wrap="true" DataKeyNames="MKTID" HeaderStyle-Width="100px" ItemStyle-Width="50px" EditMode="InPlace"> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" ItemStyle-Width="60px" HeaderStyle-Width="60px"></telerik:GridEditCommandColumn> </Columns> </MasterTableView> <ClientSettings Scrolling-AllowScroll="true" Resizing-AllowColumnResize="true" Scrolling-SaveScrollPosition="true" Scrolling-FrozenColumnsCount="2" Scrolling-UseStaticHeaders="true"> <Selecting AllowRowSelect="true" /> <ClientEvents OnRowClick="RadGridSingleRowClick" /> <Scrolling AllowScroll="true" UseStaticHeaders="true" /> </ClientSettings> </telerik:RadGrid>
foreach (GridDataItem item in grid.Items) { //Get the instance of the right type GridDataItem row = item as GridDataItem; try { string sColName = String.Empty; string sValue = String.Empty; string sValueField = String.Empty; foreach (GridColumn col in grid.MasterTableView.Columns) { sColName = col.UniqueName; if (sColName.Contains("String") && grid.MasterTableView.GetColumnSafe(sColName.Replace("String", "")) != null) { // If String is present we will use the numeric field equivalent without "String" for calculations sValueField = sColName.Replace("String", ""); } else { sValueField = sColName; } sValue = row[sValueField].Text.Replace("$", "").Replace(",", "").Replace("%", "").Replace("M", ""); if (sValue.IsNumeric()) { row[sColName].BackColor = ColorTranslator.FromHtml("#fce9b3"); } // Get rid of the border row[sColName].BorderColor = Color.Transparent; } }<asp:UpdatePanel ID="upnlGridOverview" runat="server" UpdateMode="Conditional"> <ContentTemplate> <telerik:RadGrid ID="gridOverview" runat="server" AllowPaging="True" AllowSorting="True" AllowCustomPaging="True" ShowGroupPanel="false" AutoGenerateColumns="false" PageSize="10" MasterTableView-AllowCustomPaging="true" Skin="swExcel2010" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false" ShowFooter="false" OnNeedDataSource="gridOverview_NeedDataSource"> <MasterTableView TableLayout="Fixed" OverrideDataSourceControlSorting="true" Width="100%" Visible="true"> <PagerTemplate> <uc1:GridPagerTemplate ID="GridPagerTemplate2" runat="server" /> </PagerTemplate> <PagerStyle AlwaysVisible="true" /> <NoRecordsTemplate> <uc2:GridNoRecordsTemplate ID="GridNoRecordsTemplate1" runat="server" /> </NoRecordsTemplate> <Columns> <telerik:GridBoundColumn UniqueName="Date" SortExpression="GroupDate" HeaderText="Date" DataField="DateString" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Left" FooterAggregateFormatString="Total Dates: {0:#,0}" FooterStyle-HorizontalAlign="Right" Aggregate="Count"> <HeaderStyle></HeaderStyle> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="Visitors" DataFormatString="{0:#,0}" SortExpression="Visitors" HeaderText="Visits" DataField="Visitors" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" FooterAggregateFormatString="Avg: {0:#,0}" FooterStyle-HorizontalAlign="Right" Aggregate="Avg"> <HeaderStyle></HeaderStyle> </telerik:GridBoundColumn> </Columns> <SortExpressions> </SortExpressions> </MasterTableView> <GroupingSettings GroupContinuesFormatString="" GroupContinuedFormatString="" /> </telerik:RadGrid> </ContentTemplate> </asp:UpdatePanel>
Private Sub rgLec_ItemCreated(sender As Object, e As GridItemEventArgs) Handles rgLec.ItemCreated If (bPrintReport And (TypeOf e.Item Is GridHeaderItem)) Then For Each cell As TableCell In e.Item.Cells cell.Style("text-align") = "left" Next End IfEnd Sub