2
Answers

LinkButton event is not firing in DataGrid

Ask a question
suresh

suresh

11y
2.3k
1

Hi,
Below is the code the linkbutton is not firing the event.

 <asp:DataGrid ID="user_info" DataKeyField="c_id" runat="server" >
    <Columns>       
     <ItemTemplate>
        <asp:LinkButton ID="lnkbtn" CommandName="cmdview" OnCommand="lnkbtn_Command" runat="server" Text="View"  ></asp:LinkButton>
        </ItemTemplate>
    </Columns>       
   </asp:DataGrid>

 protected void lnkbtn_Command(Object sender, CommandEventArgs e)
    {
        if (e.CommandName == "cmdview")
        {
            Response.Redirect("http://google.com");
        }
    }

Please help me,
Thanks

Answers (2)