Click here to Skip to main content
16,012,107 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im trying to delete a gridview row on hyperlink click

this is my hyper link

HTML
<a href='<%=ResolveUrl("~/Producter/Delete?id=" + id) %>' ID="A2">Delete</a>

id is a variable that i want to assign value to, this is my GridView1_RowDataBound

C#
 int id ;

  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
      // somthing like
      // selected row have this id => DataBinder.Eval(e.Row.DataItem, "Id").ToString();
      // e.Row.Attributes.Add("Onclick", id = this clicked row's id); 
    }
}
Posted

1 solution

XML
<asp:TemplateField HeaderText="Case Number">
<ItemTemplate>
<asp:Label ID="lblCaseID" runat="server" Text='<%#Eval("CID")%>' Visible="false"></asp:Label>
<asp:LinkButton ID="lblCNumber" Width="100px" runat="server" Text='<%#Eval("CName")%>'
CommandArgument='<%#bind("CID") %>' CommandName="delete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
 
Share this answer
 
Comments
BahaaAlashi 26-Apr-13 4:29am    
i dont need to have a column with the id.
Thats not what i needed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900