Quote:
access linkbutton in link button click event inside itemtemplate in gridview
Not sure what value you are trying to access , assuming Row Values of the Clicked Row.
One way is to add Click event for the LinkButton Control inside the ItemTemplate
protected void lnkBtn_Click(object sender, EventArgs e)
{
GridViewRow gridrow = (GridViewRow)((LinkButton)sender).NamingContainer;
string value = gridrow.Cells[0].Text;
Label lblControl = (Label)gridrow.FindControl("ControlID");
string value = lblControl.Text;
}
Or other way is to Add CommandArgument and CommandName to the Link Button and use the RowCommand Event of the GridView Control . The CommandArgument should be bound with the value needed to fetch
like
CommandArgument='<%# Eval("ID") %>' and CommandName="lnkClick"
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "lnkClick")
{
String ID = e.CommandArgument.ToString();
}
}