Link to home
Start Free TrialLog in
Avatar of beginner_help
beginner_help

asked on

How to change background color of RADGRID control row based the column values?

Hi
I am using Telerik RadGrid control to display display from a dataset.
Based on the data in a particular column of the row I would like to display different background color for different rows.
Let me say for example I have column called MARKS in my grid, if this column in a row null, then the I want that row background color to be RED.
How ca I do this? Where should I bind this event?
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Praveen Kumar
Praveen Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of beginner_help
beginner_help

ASKER

In my RADGRID I am displaying the value in the grid using LABEL to display the value.
So when I am using if (int.Parse(dataBoundItem["NBR"].Text) == null ), it always returning since the dat is in the label.
I tried to use FINDCONTROL to find find the label, but it is throwing exception.
Label lbl=(Label)FindControl("lblNbr");


<telerik:RadGrid AllowPaging="true" ID="grdQueues" runat="server" OnSelectedIndexChanged="grd_SelectedIndexChanged"  
                        ShowStatusBar="true" AllowSorting="true" PageSize="10" AutoGenerateColumns="false" 
                        OnPageIndexChanged="grd_PageIndexChanged" OnNeedDataSource="grd_NeedDataSource"
                        Width="100%" Visible="false" OnExcelMLExportStylesCreated="grd_ExcelMLExportStylesCreated"
                        OnExcelMLExportRowCreated="grd_ExcelMLExportRowCreated">             
                    <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" PagerTextFormat="Change page: {4} | Displaying page {0} of {1} |, items {2} to {3} of {5}." />
                    <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
                        <Selecting AllowRowSelect="true" />
                        <Scrolling AllowScroll="true" UseStaticHeaders="true" />                        
                    </ClientSettings>
                    <MasterTableView ShowHeadersWhenNoRecords="true" EditMode="PopUp">      
                        <NoRecordsTemplate><div align="center">
                                No Records to Display
                            </div>
                        </NoRecordsTemplate>
                        <Columns>
                            <telerik:GridTemplateColumn HeaderText="Acct Nbr">
                                <ItemTemplate>
                                    <asp:Label ID="lblNbr" ClientIDMode="Static" runat="server" Text='<%# Bind("NBR") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                                    <HeaderStyle HorizontalAlign="Center" Font-Bold="true" />
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="Customer Name">
                                <ItemTemplate>
                                    <asp:Label ID="lblName" ClientIDMode="Static" runat="server" Text='<%# Bind("NAME") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                                    <HeaderStyle HorizontalAlign="Center" Font-Bold="true" />
                            </telerik:GridTemplateColumn>                            
                        </Columns>                       
                    </MasterTableView>                      
                    </telerik:RadGrid>

Open in new window