DropDownList1 通过数据库绑定 如果我选择了“中国” 那么页面刷新一次, DropDownList2 (通过数据库绑定)相应显示广东省(第一个)、浙江省、、、、、然后下面就是我想要的效果:gridview1(数据库绑定,通过数据库控件根据DropDownList2中的值)显示相应的数据如:广州、肇庆、、、、、、、我的问题:重新选择DropDownList1的项,页面刷新了,DropDownList2的项也改了,但是gridview没有变 ,怎么解决?这就是DropDownList的联动问题么? 

解决方案 »

  1.   

    DropDownList autopostback=true +  selectindexchanged事件  
      

  2.   

    把3个控件全部放到 updatePanle中进行无刷新
      

  3.   

    在选择DropDownList1后改了DropDownList2的项,然后有没有继续去改gridview?
    没有的话gridview不会变的吧
    在DropDownList2的项更新后,应该按新的DropDownList2的项,或用第一个去查gridview的值显示出来吧。
      

  4.   

    在page_load中:
    if(!ispostback)
    {
        //绑定DropDownList1
        //通过DropDownList1的选择项绑定DropDownList2
    }
    //通过DropDownList2的选择项绑定gridview1
    ============================================
    DropDownList1的autopostback=true
    DropDownList1的selectedindexchanged事件中:
    {
      //绑定DropDownList2
    }
    ============================================
    的autopostback=true
    DropDownList2的selectedindexchanged事件中:
    {
      //这步可以不用(通过DropDownList2的选择项绑定gridview1) 
    }
      

  5.   

    dropdownlist  autopostback=true  + selectindexchanged事件
    重新选择DropDownList1的项,页面刷新了,DropDownList2的项也改了,但是gridview没有变
    ===
    这个要看你自己的想法了,你是想按哪个来绑定gridview,刷新时更改查询条件
      

  6.   

      <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        <div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                   <asp:DropDownList ID="ddl" runat="server" Width="15%" AutoPostBack="True" OnSelectedIndexChanged="ddl_SelectedIndexChanged">
                   </asp:DropDownList>
                     <asp:DropDownList ID="ddlChild" runat="server" Width="20%">
                   </asp:DropDownList>
                     </ContentTemplate>
            </asp:UpdatePanel>
            </div> 
     protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(this.ddl.SelectedValue!=null)
            {        }
        }
      

  7.   

    他其实就是DropDownList1一变 gridview就变的
      

  8.   

    gridview 是由数据库控件绑定的,但是数据库的配制有个where 语句 id=DropDownList2的值(我以为重选DropDownList1,DropDownList2刷新了,gridview也会跟着刷新,但是没有)
      

  9.   

    因为你DropDownList2刷新了是在后台变了值 不会 触发 DropDownList2 的 selectindexchanged 好像所以应该手动去更新一下吧
      

  10.   

    直接用js啊! 在网上也可以下载到这种js的源码!!!