值这里是我的代码ASP.NET充分利用GridView的
protected void GridView1_DeletingRow(object sender, EventArgs e)
{
Functions con = new Functions();
SqlConnection con1 = con.get();
con1.Open();
TextBox1.Visible = true;
Button1.Visible = true;
string z = TextBox1.Text;
GridView1.EnableViewState = true;
string name = GridView1.SelectedRow.Cells[1].Text;
SqlCommand com3 = new SqlCommand("select id from products where product
= '" + name + "' ", con1);
SqlDataReader read1 = com3.ExecuteReader();
read1.Read();
string pro = read1["id"].ToString();
SqlCommand com = new SqlCommand("UPDATE CartItems SET quantity = '" + z
+ "' where productid = '" + pro + "' ", con1);
}
错误:
Line 92: string name = GridView1.SelectedRow.Cells[1].Text;
异常详细信息:System.NullReferenceException:对象不设置到对象的实例。
究竟是什么错误? ,我该如何解决它?
可能重复[什么是NullReferenceException,以及如何解决它?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-doi-i-fix -it) –