asp c# .net GridView使用 Visible="false"隐藏以后如何获取到值
可以使用模板列,前台代码:
<asp:TemplateField HeaderText="id" Visible="False">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("loginID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
后台可通过
GridView3.Rows[e.RowIndex].FindControl("Label1") as Label).Text
就可以获得隐藏列的值
第一个:
<asp:TemplateField Visible="False"><ItemTemplate>
<asp:Label ID="LblGoodsID" runat="server" Text='<%# bind("cGoodsID") %>'></asp:Label>
</ItemTemplate></asp:TemplateField>
第二个:

本文详细介绍了ASP.NET中四种不同的代码插入格式,重点讲解了<%%>、<%#%>、<%=%>和<%$%>在GridView模板列中的应用。特别是<%#%>用于数据绑定,需要调用DataBind()方法;<%=%>主要用于输出,而<%$%>则用于绑定web.config中的配置项。注意各种语法在服务器控件和客户端控件中的适用性。

3万+

被折叠的 条评论
为什么被折叠?



