源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

GridView中动态设置CommandField是否可用或可见的小例子

  • 时间:2022-08-27 08:45 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:GridView中动态设置CommandField是否可用或可见的小例子
[u]复制代码[/u] 代码如下:
 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;                 }             }         }  
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部