当前位置:编程学习 > C#/ASP.NET >>

dropdownlist传递不了数据

我从数据库绑定数据在dropdownlist中,选择其中一项在gridview中显示相应的数据,但参数的值传递不过来,这是我的代码,希望大家可以帮帮我。(在线等答案)
 protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {

            DataTable dt;
            int dtCount;
            BLL.PublicMethod mymethod = new BLL.PublicMethod();
            CanLeiDaiMa = Convert.ToInt32(this.DropDownList2.SelectedValue.ToString());
     
            dt = mymethod.TiQuCaiYaoLeiXing();
            dtCount = dt.Rows.Count;

            if (dtCount > 0)
            {
                this.GridView2.DataSource = dt;
                this.GridView2.DataBind();

            }
           
 
           
        } --------------------编程问答-------------------- autopostback=true
if(!ispostback)
{
//绑定写在这里
} --------------------编程问答-------------------- 联动吧,alter一下this.DropDownList2.SelectedValue
自己再看看吧 --------------------编程问答-------------------- autopostback勾上 --------------------编程问答-------------------- F11单步
autopostback=true
if(!IsPotBack)Bind --------------------编程问答-------------------- if(!this.IsPostBack)试试啊, --------------------编程问答--------------------
引用 1 楼 flyerwing 的回复:
autopostback=true
if(!ispostback)
{
//绑定写在这里
}

调试 --------------------编程问答-------------------- 高度跟踪一下,看过去的值是什么 --------------------编程问答-------------------- 调试跟踪 --------------------编程问答-------------------- CanLeiDaiMa = Convert.ToInt32(this.DropDownList2.SelectedValue.ToString());

你这句话 起了什么做用???

BLL.PublicMethod mymethod = new BLL.PublicMethod();
this.GridView2.DataSource = dt;
this.GridView2.DataBind();

和你的 dl 有什么关系??? --------------------编程问答-------------------- 不知所云 --------------------编程问答-------------------- 2楼的就可以了

代码应该没有问题 --------------------编程问答-------------------- 改一下TiQuCaiYaoLeiXing方法。将this.DropDownList2.SelectedValue做为参数传过去。
--------------------编程问答-------------------- autopostback=true
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,