Reputation: 274
How can I get a Product_ID
from a gridviewrow without creating a column because every time I have to make the column visible and invisible to perform gridview data operation.
Thanks in advance.
Upvotes: 0
Views: 433
Reputation: 781
<asp:TemplateField HeaderText="Name" SortExpression="name" visible="False">
<ItemTemplate>
<asp:label id="prodId" runat=server" Text="<%# Eval("id")%>" ></asp:label>
</ItemTemplate>
Upvotes: 0
Reputation: 14460
<asp:HiddenField ID="HiddenField1" runat="server" Value"<%# Eval("id")%>" />
Upvotes: 0
Reputation: 2256
Make it part of one of your columns using a label similar to this:
<asp:TemplateField HeaderText="Name" SortExpression="name">
<ItemTemplate>
<asp:Label ID="productdIdLabel" runat="server" Text='<%# bind("Product_ID") %>' Visible="false"></asp:Label>
<asp:Label Visible="true" runat="server" ID="productNameLabel" Text='<%# bind("Product_Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Hope this helps! Cheers
Upvotes: 2