Dropdownlist,panel,用法(紧急求助)
protected void Page_Load(object sender, EventArgs e){
if (IsPostBack)
{
if (this.Ddlpickdbname.Items[0].Selected)
{
this.tablename = "Bookinfo";//图书表名
this.Plpobook.Visible = true;
this.Plpoperiod.Visible = false;
this.Plpo易做图.Visible = false;
this.Plpospedoc.Visible = false;
this.Plpovideo.Visible = false;
}
else if (this.Ddlpickdbname.Items[1].Selected)
{
this.tablename = "Periodinfo";//期刊表
this.Plpoperiod.Visible = true;
this.Plpobook.Visible = false;
this.Plpo易做图.Visible = false;
this.Plpospedoc.Visible = false;
this.Plpovideo.Visible = false;
}
else if (this.Ddlpickdbname.Items[2].Selected)
{
this.tablename = "Paperinfo";//论文表
this.Plpo易做图.Visible = true;//显示panel1
this.Plpobook.Visible = false;
this.Plpoperiod.Visible = false;
this.Plpospedoc.Visible = false;
this.Plpovideo.Visible = false;
}
else if (this.Ddlpickdbname.Items[3].Selected)
{
this.tablename = "Spedocinfo";//特殊文献表
this.Plpospedoc.Visible = true;// 显示panel2
this.Plpobook.Visible = false;
this.Plpo易做图.Visible = false;
this.Plpoperiod.Visible = false;
this.Plpovideo.Visible = false;
}
else if (this.Ddlpickdbname.Items[4].Selected)
{
this.tablename = "Videoinfo";//音像文献表
this.Plpovideo.Visible = true; //显示panel3
this.Plpobook.Visible = false;
this.Plpoperiod.Visible = false;
this.Plpo易做图.Visible = false;
this.Plpospedoc.Visible = false;
}
PODB();//调用帮定函数
}
}
每一个panel1里面都放有一个gridview,当下拉列表框(Ddlpickdbname)中选中第一项时,显示panel1,帮定图书表;选中第二项,显示panel2,帮定期刊表,以此类推。。
Ddlpickdbname的autopostback属性已经选为true
运行没有错误,但是当下拉列表框(Ddlpickdbname)中选中第一项时,显示panel1,gridview中也会显示图书信息,
选其它四项时都不会对应显示数据
怎么回事?
--------------------编程问答-------------------- 在Ddlpickdbname 的SelectedIndexChanged 事件中写 --------------------编程问答-------------------- 以上代码放到Ddlpickdbname的selectIndexChanged事件里 --------------------编程问答-------------------- 楼上两位正解!!! --------------------编程问答-------------------- up --------------------编程问答-------------------- 在page_load中写,当然每次都是执行if
this.tablename = "Bookinfo";//图书表名
this.Plpobook.Visible = true;
this.Plpoperiod.Visible = false;
this.Plpo易做图.Visible = false;
this.Plpospedoc.Visible = false;
this.Plpovideo.Visible = false; --------------------编程问答--------------------
补充:.NET技术 , ASP.NET