隐藏和显示datagrid列 [英] hide and visible the column of datagrid

查看:60
本文介绍了隐藏和显示datagrid列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在制作一个asp.net Web应用程序.我有一个数据网格,其中我有9列
其中开始的两个是固定的,而重新开始的六个则取决于权利.
在管理部分中,我提到了这七个列以及每个列前面的复选框,用于设置状态.我将3列的状态设置为true,将4列的状态设置为true,将false设置为false,这是我要保存在数据库中的内容..

现在,状态为1的地方我想显示该列,状态为0的地方我想隐藏该列..

如何在datagrid中完成..
在此先感谢

Hello to all i am making an asp.net web application..I have a data grid, In that i have 9 columns
in which starting two are fixed and reamining six depends on rights..
In admin section i have mention these seven columns and a check box in front of each column for setting status..now supp. i set status true for 3 columns ''true'' and ''false'' for four columns and that thing i am saving in database..

now the place where status is 1 i want to show that column and the place where status is 0 i want to hide that column..

how it will be done in datagrid..
thanks in advance

推荐答案

对sankar的改进答案

Improvement to sankar answer

// if you want hide/show in page load go for RowDataBound event.
protected void gvTesting_RowDataBound(object sender, GridViewRowEventArgs e)
{
//for column 1
 if(status==1)
  {
     gvTesting.Columns[0].Visible = true;
  }
  else
  {
     gvTesting.Columns[0].Visible = true;
  }

}


gvTesting.Columns("Name").Visible = true


这篇关于隐藏和显示datagrid列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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