我想从密码背后的电网观点中获取一个隐蔽领域的价值,但不在<代码>_RowDataBound或任何其他类似方法中使用。 这里是我目前的法典(它是一种购物假想):
<asp:GridView ID="gvShoppingCart"
runat="server"
AutoGenerateColumns="False"
AllowPaging="True"
DataKeyNames="ID"
ShowFooter="true">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="lblProductID" runat="server" Text= <%# Eval("ProductID") %> />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Product">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl= <%# Eval("ProductID", "product_details.aspx?id={0}") %>
Text= <%# GetProduct(Eval("ProductID")) %> ></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox ID="txtQuantity" runat="server" Width="35" CssClass="input" onkeypress="return isNumberKey(event)" AutoPostBack="true" ontextchanged="txtQuantity_TextChanged"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
For the sake of brevity I removed certain fields since they are there only for the display. The Quantity field is there for the user to input a number to add a number of products to his cart. I wish to access the lblProductID
label in the _TextChanged
event. In this same event, I tried
but it didn t work and returns only a null value. What is the solution?