Hi,
How can i Add LinkButton Control to GridView in asp.net.
Thanks, in advance
How to Add LinkButton Control
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mittal Sejpal75 reputationPosted Aug 25, 2011, 8:26 PM EDT
then in that template
in Item template add link button from tool box...
try it....
Purushottam RathoreRank #120 · 18.2K reputationPosted Aug 25, 2011, 8:55 PM EDT
Write the following code for using Link button in gridview.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%" OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Approve" ItemStyle-Width="150px">
<ItemTemplate>
<asp:LinkButton ID="LinkButtonDelete" Text="Delete" CommandName="Delete" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "id")%>'/>
ItemTemplate>
asp:TemplateField>
Columns>
asp:GridView>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
try
{
int id= int.Parse(e.CommandArgument.ToString());
//Delete statement;
//.................
}
catch (Exception ex)
{
ErrorMessage.Text = ex.Message;
}
}
}