My intention is diseable RequiredFieldValidator in grid view row. To find this validator i'am using FindControl method. I wrote this code:
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EditRow")
{
int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
GridView2.EditIndex = rowIndex;
RequiredFieldValidator field46 = ((RequiredFieldValidator)GridView2.Rows[rowIndex].FindControl("RequiredFieldValidator46"));
field46.Visible = false;
ZaladujGridView();
}
}
but when i press on "Edit" link button on grid view i'am receiving error "object reference not set to an instance of an object" in this line:
field46.Visible = false;
Can You help me with that ?.