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

strike out a value of a column based on some conditions

1 Answer 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dawson
Top achievements
Rank 1
Dawson asked on 08 Oct 2013, 01:10 PM

Hi,

How to strike out a value of a column based on some conditions. Anyone can show me a sample?

Thanks,
Dawson.

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 08 Oct 2013, 01:15 PM
Hi Dawson,

Please try the following code snippet to achieve your required scenario.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"      onitemdatabound="RadGrid1_ItemDataBound">
    <MasterTableView DataKeyNames="OrderID">
        <Columns>
            <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" />
            <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        string val = item.GetDataKeyValue("OrderID").ToString();//Access the DataKeyValue       
        TableCell cell = item["ShipCity"];//Access cell value of Column that you want to strike
        if (Condition)
        {
            cell.CssClass = "text";               
        }
    }
}

CSS:
<style type="text/css">
 .text
   {
    text-decoration: line-through;
   }
</style>

Thanks.
Shinu
Tags
Grid
Asked by
Dawson
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or