This is a migrated thread and some comments may be shown as answers.

Template(Col Span) |Reference for Conditional formatting

2 Answers 21 Views
Grid
This is a migrated thread and some comments may be shown as answers.
VIRUX
Top achievements
Rank 1
VIRUX asked on 23 Nov 2009, 08:39 AM
Hi,

Please tell me how to get the reference for the col span template column value like in demo ...
( Have to make conditional formatting for the value) ..
Thank you so much..
Rgd,,

              Contact Detail
Contact Name | Contact Title
---------------------------------------------
value 1            |  value 2
value 1.1         |  value 2.1


//
if value 1 is > 0 , color = red
if value 2 is < 100, color = blue




2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 23 Nov 2009, 11:10 AM
Hello,

You can replace your DataBoundLiteralControls with LabelControls and then formatt you labels conditionally. Here is an example:
aspx:
<ItemTemplate> 
    <table cellspacing="0"  width="100%" class="myTable"
        <tr> 
            <td id="td1" runat="server" style="width: 50%"
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("Value1") %>'></asp:Label> 
                                                     
            </td> 
            <td id="td2" runat="server" style="width: 50%"
                <asp:Label ID="Label2" runat="server" Text='<%# Eval("Value2") %>'></asp:Label> 
                 
            </td> 
        </tr> 
    </table> 
</ItemTemplate> 

c#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
 
            Label lbl1 = (Label)dataItem.FindControl("Label1"); 
            int value1 = Convert.ToInt16(lbl1.Text); 
            if (value1 > 0) 
            { 
                lbl1.ForeColor = System.Drawing.Color.Red; 
            } 
 
            Label lbl2 = (Label)dataItem.FindControl("Label2");             
            int value2 = Convert.ToInt16(lbl2.Text);             
            if (value2 < 100) 
            { 
                lbl2.ForeColor = System.Drawing.Color.Blue; 
            } 
        } 
    } 

Thanks
Princy.
0
VIRUX
Top achievements
Rank 1
answered on 24 Nov 2009, 12:58 AM
Hi princy,,

Thank you for your prompt responding with detail code.
I've been stuck for a day with that one. :D

best rgd,
Tags
Grid
Asked by
VIRUX
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
VIRUX
Top achievements
Rank 1
Share this question
or