DateList中的EditItemTemplate模板中的DropDownList数据绑定
stringhis_id=DataList1.DataKeys[e.Item.ItemIndex].ToString();stringsql_pro="Execselec...
string his_id = DataList1.DataKeys[e.Item.ItemIndex].ToString();
string sql_pro = "Exec select_pro_update @his_id='" + his_id + "'";
SqlConnection sqlcon = DB.createCon();
sqlcon.Open();
SqlCommand cmd = new SqlCommand(sql_pro, sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
((DropDownList)e.Item.FindControl("ddl_pro")).DataSource = sdr;
((DropDownList)e.Item.FindControl("ddl_pro")).DataTextField = "pro_name";
((DropDownList)e.Item.FindControl("ddl_pro")).DataValueField = "pro_id";
((DropDownList)e.Item.FindControl("ddl_pro")).DataBind();
sdr.Close();
sqlcon.Close();
执行错误, 未将对象引用设置到对象的实例。 展开
string sql_pro = "Exec select_pro_update @his_id='" + his_id + "'";
SqlConnection sqlcon = DB.createCon();
sqlcon.Open();
SqlCommand cmd = new SqlCommand(sql_pro, sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
((DropDownList)e.Item.FindControl("ddl_pro")).DataSource = sdr;
((DropDownList)e.Item.FindControl("ddl_pro")).DataTextField = "pro_name";
((DropDownList)e.Item.FindControl("ddl_pro")).DataValueField = "pro_id";
((DropDownList)e.Item.FindControl("ddl_pro")).DataBind();
sdr.Close();
sqlcon.Close();
执行错误, 未将对象引用设置到对象的实例。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询