简体   繁体   English

从隐藏的ItemTemplate字段中获取值

[英]Capture Value From Hidden ItemTemplate Field

I have a gridview and I need to capture the value of my label, but have it not be displayed. 我有一个gridview,我需要捕获标签的值,但是不显示它。 ANytime I set it to hidden I am no longer able to capture the value. 每次我将其设置为hidden我将不再能够捕获该值。 What should I alter so the label is hidden, but I still am able to capture the value? 我应该怎么做才能隐藏标签,但仍然可以获取价值? eghead is what I am wanting to hide but still capture the value of eghead是我要隐藏的东西,但仍然可以捕捉到价值

<td valign="top" style="text-align: left; width: 200px;">
<asp:GridView runat="server" ID="gridview1" AutoGenerateColumns="false" GridLines="Both" ShowFooter="true" >
    <Columns>
    <asp:BoundField DataField="rdf" HeaderText="redfern" />
    <asp:TemplateField>
        <ItemTemplate>
            <asp:Label runat="server" Text='<%#Eval("egh") %>' ID="eghead" ></asp:Label>
            <asp:CheckBox ID="Sans" runat="server" AutoPostBack="false" Checked='<%# Convert.ToBoolean(Eval("Remember")) %>' />
        </ItemTemplate>
    </asp:TemplateField>
    </Columns>
</asp:GridView>                                

use the 使用

 style="display:none"

in the control. 在控制中。 This way it will not be displayed in the UI but it will be available in the client side for manipulation. 这样,它不会显示在UI中,但可以在客户端进行操作。

Another alternative is to set a property of your checkbox and then use it using jquery or using javascript method. 另一种选择是设置复选框的属性,然后通过jquery或javascript方法使用它。 The asp.net renders the custom property as it is on client side. asp.net呈现自定义属性,就像在客户端一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM