Hi
This is my code for update when i click update button in grid view it shows this error "Object reference not set to an instance of an object whats this error"
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
int Id = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
int intResult = 0;
TextBox Name = (TextBox)row.FindControl("txtname");
TextBox Phonenumber = (TextBox)row.FindControl("txtPhonenumber");
TextBox Emailaddress = (TextBox)row.FindControl("txtmailid");
TextBox Dob = (TextBox)row.FindControl("txtdob");
TextBox Address = (TextBox)row.FindControl("txtadd");
TextBox City = (TextBox)row.FindControl("txtcity");
clsBAL pBAL = new clsBAL();
try
{
intResult = pBAL.Updatecontact(Id,Name.Text,Phonenumber.Text,Emailaddress.Text,Dob.Text,Address.Text,City.Text);
if (intResult > 0)
lblMessage.Text = "Record is Updated";
else
lblMessage.Text = "Record cannot update";
}
catch (Exception ex)
{
lblMessage.Text = ex.Message.ToString();
}
finally
{
pBAL = null;
}
GridView1.EditIndex = -1;
BindGrid1();
}
SATHIYANARAYANAN
Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator