GridViewRow gr = GridView1.Rows[e.RowIndex] as GridViewRow;
TextBox t6 = gr.FindControl("txtEmpid") as TextBox;
TextBox t3 = gr.FindControl("txtName") as TextBox;
TextBox t5 = gr.FindControl("txtEmailid") as TextBox;
SqlConnection conn = new SqlConnection(@"Data Source=ARVIND-VAIO\ARVIND;Initial Catalog=ARVIND;Integrated Security=True");
SqlCommand cmd = new SqlCommand("update Emp_info set Name='"+t3.Text+"',Emailid='"+t5.Text+"' where Empid='"+t6.Text+"'", conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
display();
I am getting error Object reference not set to an instance of an object.
The error is on the line with the
SqlCommand
call.