未将对象引用设置到对象的实例问题
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e) { //string courseid = ((TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text.ToString().Trim(); //string courseid = ((TextBox)e.NewValues["courseid"]).Text.ToString().Trim(); string coursename = ((Label)ListView1.Items[e.ItemIndex].FindControl("coursenameTextBox")).ToString().Trim();//这句提示有问题 string teacher = ((Label)ListView1.Items[e.ItemIndex].FindControl("teacherTextBox")).ToString().Trim(); SqlConnection conn = new SqlConnection(WebConfigurationManager.AppSettings["strConn"].ToString()); SqlCommand comm = new SqlCommand("update courseinfo set coursename=✀" + coursename + "✀,teacher=✀" + teacher + "✀ where courseid=✀" + ListView1.DataKeys[e.ItemIndex].Value.ToString() + "✀", conn);