如何隐藏一列(GridView)但仍然访问它的值? [英] How to hide a column (GridView) but still access its value?

查看:25
本文介绍了如何隐藏一列(GridView)但仍然访问它的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 DataSource(SQL 数据库)的 GridView.我想隐藏一列,但在选择记录时仍然能够访问该值.有人可以告诉我怎么做吗?

I have a GridView with a DataSource (SQL Database). I want to hide a column, but still be able to access the value when I select the record. Can someone show me how to do this?

这是我想隐藏但仍想访问其值的列:

This is the column I want to hide and still want to access its value:

<asp:BoundField DataField="Outlook_ID" HeaderText="OutlookID" />

我尝试了所有方法来隐藏该列(属性 Visible="false"),但我无法访问它的值.

I tried everything to hide the column (property Visible="false"), but I can't access its value.

推荐答案

如果我没记错的话,GridView 不保存具有 BoundColumns 属性的值 <代码>visible="false".您可以在这里做两件事,一件事(如 V4Vendetta 的回答中所述)使用 Datakeys.或者您可以将 BoundColumn 更改为 TemplateField.在 ItemTemplate 中,添加一个类似 Label 的控件,使其可见性为 false 并将您的值赋予该 Label.

If I am not mistaken, GridView does not hold the values of BoundColumns that have the attribute visible="false". Two things you may do here, one (as explained in the answer from V4Vendetta) to use Datakeys. Or you can change your BoundColumn to a TemplateField. And in the ItemTemplate, add a control like Label, make its visibility false and give your value to that Label.

这篇关于如何隐藏一列(GridView)但仍然访问它的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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