手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >GridView中动态设置CommandField是否可用或可见的小例子
GridView中动态设置CommandField是否可用或可见的小例子
摘要:复制代码代码如下: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;

}

}

}

【GridView中动态设置CommandField是否可用或可见的小例子】相关文章:

ASP.NET设计网络硬盘之文件夹实现

上传图片后使用数据库保存图片的示例分享

动态加载Js代码到Head标签中的脚本

Asp.Net 上传图片并生成高清晰缩略图

gridview实现服务器端和客户端全选的两种方法

asp.net Context.Handler 页面间传值方法第1/2页

asp.net GridView 中增加记录的方法

解决Visual Studio 2005 无法显示设计视图的方法

GridView生成的HTML代码

在Apache环境下成功的运行ASP.NET的注意事项

精品推荐
分类导航