【发布时间】:2017-04-25 14:33:08
【问题描述】:
这是我的代码
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:对象引用未设置为对象的实例。
究竟是什么错误? ,我该如何解决?
【问题讨论】: