下拉框连动出错 救急

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确不管我选择得是小类里面得哪一项 ,它传递得值确总是最排列再最上面得那个,为什么啊 ,急死啊
...全文
124 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
kofkyo 2007-06-14
  • 打赏
  • 举报
回复
用request.form取值
ustbwuyi 2007-06-14
  • 打赏
  • 举报
回复
拜托你们把数据库操作类都封装一下
打开、关闭、执行SQL、执行存储过程、返回数据集这些
这么一大堆看着眼睛真疼
Jinglecat 2007-06-14
  • 打赏
  • 举报
回复
晕,
bigclass 绑定你放在了 !IsPostBack 里面,
smallclass 怎么不会放在 !IsPostBack 里面啊

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧