add onRowCommand event to your grid
OnRowCommand="OnRowCommand_GridView1"
Then define a Button link with CommandName and CommandArgument
<asp:LinkButton ID="lnk1" runat="server" Text="DoClick" CommandName="Select" CommandArgument='<%#Eval("FileID") %>'></asp:LinkButton>
not by code
protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
int MyFileID = e.CommandArgument;
}
Hope this helps you.
Syeda source
share