日期:2014-05-18  浏览次数:20476 次

GridView中按钮列!!
在模版列里两个按钮a和b,我想绑定数据库时检索bit类型的那一列,如果是true,就让a显示b不显示,如果是false就让a不显示b显示,请教该怎么写代码!!

------解决方案--------------------
在rowdatabond 事件中去判断数据库的值 来决定是否显示按钮
------解决方案--------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)

if (e.Row.Cells[8].Text == "USA")
{
Button btn1 = (Button)e.Row.Cells[1].Controls[0]; 
btn1.Visiable = false;
}
}
}