如何使用asp.net C#在网格视图中隐藏零列值 [英] how to hide zero column value in grid view using asp.net c#

查看:102
本文介绍了如何使用asp.net C#在网格视图中隐藏零列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i在数据库侧有一个表...它有8列字段.在那个表中只有5列值..而其他列值为零.

每当加载Default.aspx页时,时间值字段都是可见的true.其他零列值隐藏或可见的false如何编写代码.请帮助...

i have the one table in data base side...its having 8 column field.in that table having only 5 column value.. and other column value is zero.

when ever am load Default.aspx page that time value fields are visible true.other Zero column value hide or visible false how to write code..please help...

推荐答案

只需使用sql选择具有值(例如col1到col5)的那五列,例如
Just select those five columns that have value (say col1 to col5) using sql, e.g.
select col1, col2, col3, col4, col5 from tablename


以下是为您提供的示例代码
希望对您有帮助.........

Here''s a sample Code for you
Hope this help.........

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
  {
      if (<YOUR CONDITION GOES HERE>)
      {
      GridView1.Columns[0].Visible = false; // just change the index of Columns to where your Template column resides
      }
  }


快乐编码.........


Happy Coding.........


这篇关于如何使用asp.net C#在网格视图中隐藏零列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆