在运行时必须隐藏2个并发列 [英] Have to hide 2 concurrent columns at the runtime

查看:90
本文介绍了在运行时必须隐藏2个并发列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我必须在gridview中隐藏两列.

Hi,

I''ve to hide two columns in a gridview

推荐答案


检查此
Hi ,
Check this
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
 {
     e.Row.Cells[1].Visible = false;
 }



最好的问候
M.Mitwalli



Best Regards
M.Mitwalli


datagrid的所有列都从数据库表中自动更新.
要禁用列的自动生成,只需将您的数据网格的AutoGenerateColumns属性更改为false.

现在,您的数据网格没有列,您可以放入任何列.具有数据表的数据库中的列数.

我希望您知道如何在数据表中添加列.

另一个解决方案是尝试以下操作:
The all the columns of datagrid is autoupdated from the database table.
To disable the auto generation of columns, simply change the AutoGenerateColumns property to false of your datagrid.

Now your datagrid has no columns, and you can put any no. of columns from database with datatable.

I hope you know how to add columns in datatable.

The another solution is that try this:
OledbDataAdapter da = new OledbDataAdapter("select [column],[column] from [tablename]",[connection object]);
DataSet ds = new DataSet();

da.Fill(ds,"[tablename]");

GridView1.DataSource=ds.Tables("[tablename]");
GridView1.DataBind();


此代码将与msaccess数据库一起使用.

谢谢.


This code will work with msaccess database.

Thank you.


将数据源分配给网格视图之后

检查该列是否存在
喜欢

after assigning the datasource to the grid view

check if the column exists
like

id(dg.Columns.Contains("ColumnName"))
 dg.Column["ColumnName"].visible = false;


这篇关于在运行时必须隐藏2个并发列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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