我有一个radgrid,其列显示我的数据库中的值('0','1','2'),每个列分别代表(“TPA”,“Cash Claim”,“Normal Claim”)。< / p>
有没有办法显示相应值的文本而不是数值?
答案 0 :(得分:0)
您可以在后面的代码中修改Item Databound上每行的内容。如果您正在使用C#,您可以复制此示例,在itemDataBound中您只需要检查值是什么,并将列文本设置为您想要显示的内容。
<telerik:RadGrid ID="rgMyStuff" OnItemDataBound="rgMyStuff_ItemDataBound">
protected void rgMyStuff_ItemDataBound(object sender, GridItemEventArgs e)
{
if (!(e.Item is GridDataItem)) return;
GridDataItem dataBoundItem = e.Item as GridDataItem;
//I like to cast my gridDataItem back to the type that I initially set in DataSource
MyStruct dataItem = (MyStruct)dataBoundItem.DataItem;
if (dataItem.myType == 1)
dataBoundItem["MyType"].Text = "TPA";
//or you could also just use the DataBoundItem like this:
if(dataBoundItem["MyType"].Text == "1")
databoundItem["MyType"].Text = "TPA";
...
}