asp.net 数据绑定时对数据列做个性化处理
程序员文章站
2024-03-06 14:33:44
复制代码 代码如下: protected void dgquery_itemdatabound(object sender, datagriditemeventargs e...
复制代码 代码如下:
protected void dgquery_itemdatabound(object sender, datagriditemeventargs e)
{
if ((e.item.itemtype != listitemtype.header) && (e.item.itemtype != listitemtype.footer))
{
datarow drrow = ((datarowview)e.item.dataitem).row;
string commonpartid = drrow["cnibackup1"].tostring();
hyperlink hltrans = (hyperlink)e.item.findcontrol("hltrans");
if (hltrans != null)
{
hltrans.text = "--";
hltrans.navigateurl = "javascript:void();";
}
//删除列
linkbutton btndelete = (linkbutton)e.item.findcontrol("btndelete");
//没有删除权限且找到控件
if (!bcandelete && btndelete != null)
{
//查找控件所在cell列号
for (int i = 0; i < e.item.cells.count; i++)
{
if (e.item.cells[i].hascontrols() && e.item.cells[i].controls.indexof(btndelete) > 0)
{
int index = e.item.cells[i].controls.indexof(btndelete);
e.item.cells[i].controls.removeat(index);
literal tips = new literal();
tips.text = "--";
e.item.cells[i].controls.addat(index, tips);
//e.item.cells[i].text = "--";
break;
}
}
}
}
}
上一篇: 批量账号的login测试功能实现
下一篇: java中如何反射获取一个类