下拉框连动出错 救急
taogo 2007-06-14 04:29:57 protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["pid"] != null)
{
upbind();
this.Label1.Text = "产品信息修改";
}
string sql = "select bigclassname from bigclass order by listid asc";
SqlConnection proconn = Connection.getConnection();
SqlCommand procomm = new SqlCommand(sql, proconn);
SqlDataReader prord;
proconn.Open();
prord = procomm.ExecuteReader();
ArrayList myarraylist = new ArrayList();
while (prord.Read())
{
myarraylist.Add(prord.GetString(0));
}
this.probigclass.DataSource = myarraylist;
this.probigclass.DataBind();
prord.Close();
proconn.Close();
//下面填充小类下拉列表
if (Session["admin"] == null)
{
this.prousername.Text = "未登陆用户";
}
else
{
this.prousername.Text=Session["admin"].ToString();
}
}
string smallsql = "select smallclassname from [smallclass] where bigclassname='" + this.probigclass.SelectedValue + "'";
SqlConnection smallconn = Connection.getConnection();
SqlCommand smallcomm = new SqlCommand(smallsql, smallconn);
smallconn.Open();
SqlDataReader smallrd;
smallrd = smallcomm.ExecuteReader();
ArrayList smallarray = new ArrayList();
while (smallrd.Read())
{
smallarray.Add(smallrd.GetString(0));
}
this.prosmallclass.DataSource = smallarray;
this.prosmallclass.DataBind();
smallrd.Close();
smallconn.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
string prohttpen = Upload1.thisurl;
string prohttpch = Upload2.thisurl;
if (Request.QueryString["pid"] != null)
{
string id = Request.QueryString["pid"];
string sql = "update product set procontent='" + this.procontent.Value + "',protitle='" + this.protitle.Text + "',headid='" + Convert.ToBoolean(this.headid.SelectedValue) + "', probigclass='" + this.probigclass.SelectedValue.ToString() + "', prosmallclass='" + this.prosmallclass.SelectedValue.ToString() + "' where proid=" + id;
Connection.DoSql(sql);
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('产品修改成功!');</script>");
}
else
{
News pro = new News();
pro.insertpro(this.probigclass.SelectedValue, this.prosmallclass.SelectedValue, this.protitle.Text, re.replace(this.procontent.Value), this.prousername.Text, prohttpen, prohttpch, Convert.ToBoolean(this.headid.SelectedValue));
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('产品上传成功!');window.location.href='addpro1.aspx';</script>");
}
}
为什么我提交得时候,bigclass可以正确得获取到我选择得值。二,smallclass确不管我选择得是小类里面得哪一项 ,它传递得值确总是最排列再最上面得那个,为什么啊 ,急死啊