protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }
 protected void Bind()
        {
            PeopleManager pm = new PeopleManager();
            this.DropDownList1.DataSource = pm.SelTt();
            this.DropDownList1.DataTextField = "BranchName";
            this.DropDownList1.DataBind();
        } 
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddl = this.Page.FindControl("DropDownList1") as DropDownList;
            Lable1.Text = ddl.SelectedValue;        
        }
能绑定,有值,但是当选中那个下拉框的其中一个时 却取不到,请指教

解决方案 »

  1.   

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
      {
       // DropDownList ddl = this.Page.FindControl("DropDownList1") as DropDownList;
      Lable1.Text = DropDownList1.SelectedValue;   
      }
      

  2.   

    楼上的应该对
    很久没做Web,有点生疏了
      

  3.   

    检查DropDownList1是否存在重复值
    autopostback=true
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
      {DropDownList1.SelectedValue
    }
      

  4.   


    嗯 autopostbback=true确实可以娶到值了
    但是我发现这个是点击一下就回传刷新一次,界面很不友好,比如我一个登录信息框 前面输入下来,到下拉框选的时候就刷新了 有什么办法能不回传吗?
      

  5.   

    http://www.cnblogs.com/Terrylee/archive/2006/11/01/aspnet_ajax_updatepanle_part2.html
      

  6.   

    ajax updatepanel
     <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        <div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                   <asp:DropDownList ID="ddlLB" runat="server" Width="15%" AutoPostBack="True" OnSelectedIndexChanged="ddlLB_SelectedIndexChanged">
                   </asp:DropDownList>
                     </ContentTemplate>
            </asp:UpdatePanel>
            </div> 
      

  7.   

    谢谢 不过我现在还没学到ajax无刷技术,如果单纯是asp.net的角度出发的话 就只能这一种办法了吗?
      

  8.   

    .net 控件updatepane 加ajx很方便的实现回传 
      

  9.   

    是的,肯定是你没有加AutoPostBack=true这个属性
      

  10.   


    同意
    楼主记得加上updatepanle 实现无刷新
      

  11.   

    页面添加一个隐藏控件,下拉列表不加RUNAT=SERVER,调用ONCHANGE事件给隐藏控件赋值,后台判断隐藏控件是否为空,如果不为空继续下面操作希望可以帮到楼主
      

  12.   

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <asp:DropDownList ID="ddlCity" runat="server" AutoPostBack="True"/>
    </ContentTemplate>
    </asp:UpdatePanel>string a=ddlCity.SelectedValue;