Hi,
I need your help.
How to pass DataKeyNames using Image Button Row from Gridview ASP.Net?
I have this error Object reference not set to an instance of an object.
My code below
protected void btn_Click(object sender, ImageClickEventArgs e)
{
ImageButton lnkbtn = sender as ImageButton;
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
if (lnkbtn != null)
{
foreach (GridViewRow row in gvProducts.Rows)
{
//New
CheckBox chk = (CheckBox)row.FindControl("chkRow");
string lbCode = gv.DataKeys[gvrow.RowIndex].Values[0].ToString();
Response.Write(lbCode + "<br />");
}
this.BindGrid();
}
}