即使从DB获取该值,是否有可能从gridview中隐藏列? [英] Is there a possibility to hide a column from gridview even if you get that value from DB?
本文介绍了即使从DB获取该值,是否有可能从gridview中隐藏列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用数据库中的一些列填充了一个网格视图,并按照以下步骤发送参数:
I have populated a grid view with some columns from database with following procedure sending a parameter:
SqlConnection sqlConn = new SqlConnection(StringKoneksioni.Stringu);
using (sqlConn)
{
SqlCommand sqlCmd = new SqlCommand("procProcedureName", sqlConn);
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.Add(new SqlParameter("@Parameter", SqlDbType.VarChar));
sqlCmd.Parameters["@Parameter"].Value = Session["Parameter"];
sqlConn.Open();
SqlDataReader reader = sqlCmd.ExecuteReader();
gvName.DataSource = reader;
gvName.DataBind();
///All I want is to hide the following column from grid view but use its value. How to solve this?
gvName.Columns[10].Visible = false;
sqlConn.Close();
}
P.S.我的问题在上面的评论代码中设置。
提前感谢您的回复。
干杯。
P.S. My question is set on the comment code above.
Thank you in advance for your reply.
Cheers.
推荐答案
这是关于如何使用项目模板使用gridview的基本示例(而不是使用自动生成的列)。
http://www.dotnetlearners.com/blogs/view/20/aspnet-gridview-basic -example-for-insert-update-and-delete-the-records.aspx [ ^ ]
使用项目模板创建列后,您可以在数据绑定之后将列显示为false。
Here is the basic example about how to use gridview using item template (instead of using auto generated columns).
http://www.dotnetlearners.com/blogs/view/20/aspnet-gridview-basic-example-for-insert-update-and-delete-the-records.aspx[^]
Once you created the columns using item template you can then after databind just make the column visible false.
gvName.DataBind();
///All I want is to hide the following column from grid view but use its value. How to solve this?
gvName.Columns[10].Visible = false;
使用Item模板并插入隐藏值或保持方式,在特定的Bound字段中设置display:none。
Use an Item template and insert a hidden value or keeping your way , set display:none in that particular Bound field.
这篇关于即使从DB获取该值,是否有可能从gridview中隐藏列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文