插入列在GridView中隐藏字段 [英] Inserting a column with hidden field in gridview

查看:91
本文介绍了插入列在GridView中隐藏字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在网格视图中插入带有隐藏字段列。

I need to insert a column with hidden field in grid view.

用户不应该知道,一列是存在的。

The user should not know that one column is there.

我试过如下:创建CSS类的宽度显示:无; 并分配 ItemStyle-的CssClass =MyCssClass

I tried the following: created a css class width display:none; and assigned ItemStyle-CssClass="MyCssClass".

但效果不理想。

插入一个模板字段的ItemTemplate 我给了一个 ASP:HiddenField

Inserted a template field and in itemtemplate I had given a asp:HiddenField

这两种方法给出了一个额外的列隐藏字段。

Both method shows an extra column hidden field.

有是自字段被渲染为隐藏字段没有价值,但该列有宽近10个像素(看到该图片的 http://www.tiikoni.com/tis/view/?id=c500726 )。
所以用户感觉一个空行是存在的。

There is no value since the fields are rendered as hidden fields but that column have width nearly 10 pixels (see this image http://www.tiikoni.com/tis/view/?id=c500726).
So the user feels an empty row is there.

我需要完全隐藏列。

我不能使用模板字段知名度= FALSE ,因为我需要从访问其值客户端

I cannot use template field with visibility=false, because I need to access its value from client side.

推荐答案

您可以在你的任何一列的隐藏字段。并得到它从任何地方你住的价值。

这里是一个很好的链接调用从服务器端

<一href=\"http://stackoverflow.com/questions/6685939/access-hidden-field-within-gridview-control-to-set-a-value-in-javascript\">access GridView控件中的隐藏字段在JavaScript中设置值?

You can keep the hidden field in your any column. And get it's value from anywhere you live.
Here is a good link to call value from the server side
access hidden field within gridview control to set a value in javascript?

添加列如下:

<asp:TemplateField>
   <ItemTemplate>
      <<asp:Label ID="lbl1" runat="server" 
             Value='<%# Eval("Name") %>' />
      <asp:HiddenField ID="HiddenField1" runat="server" 
             Value='<%# Eval("BirthDate") %>' />
</ItemTemplate>

,你可以得到的值你隐藏轻松地整理

and you can get the values of your hidden filed easily

这篇关于插入列在GridView中隐藏字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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