2013-07-11
展开全部
1.把DropDownList1的AutoPostBack设置为true2.web程序一般是使用DropDownList1_SelectedIndexChanged事件而不是TextChanged protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{ if(string.IsNullOrEmpty(Request["DropDownList1"])) return;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["进销存ConnectionString"].ConnectionString);
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from 图书基本信息表 where 图书编号=" +Request["DropDownList1"], con);
DataSet ds = new DataSet ();
da.Fill(ds,"图书基本信息表");
DataRowView view=ds.Tables ["图书基本信息表"].DefaultView [0];
string bookids=Convert .ToString (view ["Hidden1"]);
SqlCommand cmd=new SqlCommand ("select 客户名称 from 客户基本信息表 where 客户编号="+bookids ,con );
this.TextBox7.Text = Convert.ToString(cmd.ExecuteScalar());
this.Hidden1.Value = bookids;
bookclass ss = new bookclass();
Session["snum"] = ss.stock(Convert.ToInt32(view["图书编号"])) - ss.sell(Convert.ToInt32(view["图书编号"]));
this.TextBox2.Text = Convert.ToString(ss.stock(Convert.ToInt32(view["图书编号"])) - ss.sell(Convert.ToInt32(view["图书编号"])));
}
{ if(string.IsNullOrEmpty(Request["DropDownList1"])) return;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["进销存ConnectionString"].ConnectionString);
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from 图书基本信息表 where 图书编号=" +Request["DropDownList1"], con);
DataSet ds = new DataSet ();
da.Fill(ds,"图书基本信息表");
DataRowView view=ds.Tables ["图书基本信息表"].DefaultView [0];
string bookids=Convert .ToString (view ["Hidden1"]);
SqlCommand cmd=new SqlCommand ("select 客户名称 from 客户基本信息表 where 客户编号="+bookids ,con );
this.TextBox7.Text = Convert.ToString(cmd.ExecuteScalar());
this.Hidden1.Value = bookids;
bookclass ss = new bookclass();
Session["snum"] = ss.stock(Convert.ToInt32(view["图书编号"])) - ss.sell(Convert.ToInt32(view["图书编号"]));
this.TextBox2.Text = Convert.ToString(ss.stock(Convert.ToInt32(view["图书编号"])) - ss.sell(Convert.ToInt32(view["图书编号"])));
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询