如何在行中绘制单元格(Telerik)?

时间:2017-08-01 12:03:01

标签: asp.net webforms telerik

我下一个处理fow格式化我的单元格的代码:

grep '"Missing description!"' filename.html

但是我的细胞没有画画。如何在dataBinding上绘制一些行中的单元格?

1 个答案:

答案 0 :(得分:1)

看起来这样做的正确事件是ItemDataBound事件。见这里:

http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/appearance-and-styling/conditional-formatting

protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
//Is it a GridDataItem
if (e.Item is GridDataItem)
{
    //Get the instance of the right type
    GridDataItem dataBoundItem = e.Item as GridDataItem;

    //Check the formatting condition
    if (int.Parse(dataBoundItem["Size"].Text) > 100)
    {
        dataBoundItem["Received"].ForeColor = Color.Red;
        dataBoundItem["Received"].Font.Bold = true;
        //Customize more...
    }
}
}

或者更好的事情是使用自定义CSS类,以便以后可以进行更改而无需重建项目:

protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e){
if (e.Item is GridDataItem)
{
    GridDataItem dataItem = e.Item as GridDataItem;
    if (dataItem["Country"].Text == "Mexico")
        dataItem.CssClass = "MyMexicoRowClass";
}
}