GridView中动态设置CommandField是否可用或可见的小例子_asp.net教程-查字典教程网
GridView中动态设置CommandField是否可用或可见的小例子
GridView中动态设置CommandField是否可用或可见的小例子
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:protectedvoidgvMaterial_RowDataBound(objectsender,GridViewRow...

复制代码 代码如下:

protected void gvMaterial_RowDataBound(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)

{

e.Row.Cells[0].Visible = false;

}

if (e.Row.RowType == DataControlRowType.DataRow)

{

e.Row.Cells[1].Text = (gvMaterial.PageIndex * gvMaterial.PageSize + e.Row.RowIndex + 1).ToString();

string price;

try //让编辑功能在特定条件下可以用

{

price = ((TextBox)e.Row.Cells[4].Controls[0]).Text;//点编辑的时候用

}

catch

{

price = e.Row.Cells[4].Text; //出始时用

}

if (price == "" || price == "")

{

e.Row.Cells[7].Controls[0].Visible = false;

}

else

{

e.Row.Cells[7].Controls[0].Visible = true;

}

}

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新asp.net教程学习
    热门asp.net教程学习
    编程开发子分类