简体   繁体   中英

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. ANytime I set it to hidden I am no longer able to capture the value. 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

<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.

Another alternative is to set a property of your checkbox and then use it using jquery or using javascript method. The asp.net renders the custom property as it is on client side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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