关于GredView等数据显示控件的数据绑定

遇到问题:asp.net给控件gridview 绑定数据,需要指定某列的显示是该列的值在另一个表里面对应的文本时的写法?

解决问题:

gridview 添加事件RowDataBound添加事件中添加以下内容:

if (e.Item.ItemType == Telerik.Web.UI.GridItemType.Item || e.Item.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem)             {                 var obj = (BaseInfo_Equipment)e.Item.DataItem;                 var listItem = ddlEquipmentType.Items.FindByValue(obj.EquipmentType.ToString());                 if (listItem != null)                 {                     e.Item.Cells[4].Text = listItem.Text;                 }             }
posted @ 2012-10-22 17:40  namehwh  阅读(534)  评论(3编辑  收藏  举报