看来我的代码不完整或语法错误,但我尽力想出某种解决方案,但到目前为止没有成功......所以这就是我想要做的:我有几个下拉框,并希望将每个下拉框的选定值分配给表适配器中的值。到目前为止,这是我的代码,但不确定缺少什么:
protected void Page_Load(object sender, EventArgs e)
{
ID = Convert.ToInt32(Request.QueryString["myID"]);
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("SELECT NAME, DEPARTMENT, LOCATION from MyTable WHERE ID = '" + ID + "' ", con);
DataTable dt= new DataTable();
da.Fill(dt);
ddl_Name.SelectedValue = dt[0].Name;
ddl_DEPARTMENT.SelectedValue = dt[0].DEPARTMENT;
ddl_LOCATION.SelectedValue = dt[0].LOCATION;
}
当我输入 dt[0].Name 时,我的问题从这里开始,似乎我添加零时它不喜欢。请帮忙。谢谢