I have a gridview and in this gridview there is a buttonfield.
<asp:GridView ID="OrdersGridView" runat="server" AutoGenerateColumns="False"
onrowdeleted="OrdersGridView_RowDeleted"
onrowcommand="OrdersGridView_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Product Name">
<ItemTemplate>
<asp:HiddenField runat="server" ID="HiddenField1" Value='<%#Eval("oid")%>'></asp:HiddenField>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="titel" HeaderText="Name" />
<asp:BoundField DataField="oid" HeaderText="Itemno" />
<asp:BoundField DataField="prijs" HeaderText="Price" />
<asp:ButtonField ImageUrl="Images/close.jpg" CausesValidation="false" HeaderText="Update" Text="Delete" commandname="Del" runat="server" />
<asp:BoundField DataField="prijs" HeaderText="Subtotal" />
</Columns>
</asp:GridView>
Im testing this buttonfield with the next code
protected void OrdersGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
Check.Text = "test1";
if (e.CommandName == "Del")
{
string sValue = ((HiddenField)OrdersGridView.SelectedRow.Cells[1].FindControl("HiddenField1")).Value;
Check.Text += sValue;
}
else
{
Check.Text += "test2";
}
}
But nothing happens when I click on the buttonlink. the label Check stays empty. What am I doing wrong?