dropdownlist的问题我实现了ajax不刷新更新数据,但是我怎么用ddldownlist.selectValue;服务器的方法来获取ddldownlist.选中的值呢
我更新第二个下拉框是改变html的值
是<option >
我用ddldownlist.selectValue回报错
是不是得改viewstate的值呢怎么改呢

解决方案 »

  1.   

    document.getElementById("dropdownlist").options[document.getElementById("dropdownlist").selectedIndex].value//获得值VALUEdocument.getElementById("dropdownlist").options[document.getElementById("dropdownlist").selectedIndex].text//获得TEXT
      

  2.   

    w我是说服务器端的不是js
      

  3.   

    这个我知道到我是想如何改改就可以用selectValue取出来呢
      

  4.   

    这个我知道到我是想如何改改就可以用selectValue取出来呢
      

  5.   

    这个我知道到我是想如何改改就可以用selectValue取出来呢
      

  6.   

    用的updatepanel控件嗎?
    然后在onselectedindexchanged里抓不到值對嗎?
    貼代碼。
      

  7.   

    1.Dropdownlist的AutoPostBack="true" 
    2.Updatepanel的Trriger事件要添加!<form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
        </div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" 
                onselectedindexchanged="DropDownList1_SelectedIndexChanged">
            <asp:ListItem>1</asp:ListItem>
            <asp:ListItem>2</asp:ListItem>
            <asp:ListItem>3</asp:ListItem>
            <asp:ListItem>4</asp:ListItem>
            </asp:DropDownList>
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" ></asp:AsyncPostBackTrigger>
        </Triggers>
        </asp:UpdatePanel>
        
        </form>protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Label1.Text = DropDownList1.SelectedValue;
        }
      

  8.   

    js存到hidden里面然后从后台取
      

  9.   

    谢谢我不想用ajaxpanel
    用过几次不好用,主要是不习惯
    我是想如何改变下viewstate的值
    然后就可以用selectValue来取值了