有一个DropDownList和TextBoxDropDownList内容是从数据库中读出来的。。选择DropDownList里的项,让DropDownList的DataValueField值给TextBox比如DropDownList的值有如下DataValueField    DataTextField
1                     aaaa
2                     bbbb
3                     cccc
4                     dddd选择aaaa,TextBox=1
再选择cccc,TextBox=1,3这样的功能。。怎么实现??

解决方案 »

  1.   

    textBox.Text=textBox.Text+","+dropDownList.SelectedValue
      

  2.   

    textBox.Text=textBox.Text+","+dropDownList.SelectedValue
      

  3.   

    你把dropDownList的AUTOPOSTBACK设为TRUE就可以了
      

  4.   

    处理dropDownList的selectedIndexChanged事件。
      

  5.   

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
        <script>
            function change(objddl)
            {
                if(document.getElementById("TextBox1").value=="")
                document.getElementById("TextBox1").value +=objddl.options[objddl.selectedIndex].innerText;
                else
                document.getElementById("TextBox1").value +=","+objddl.options[objddl.selectedIndex].innerText;
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:DropDownList ID="DropDownList1" runat="server" onchange="change(this)">
            <asp:ListItem Text="aaaa" Value="1"></asp:ListItem>
            <asp:ListItem Text="bbbb" Value="2"></asp:ListItem>
            <asp:ListItem Text="cccc" Value="3"></asp:ListItem>
            <asp:ListItem Text="dddd" Value="4"></asp:ListItem>
            </asp:DropDownList><br />
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>&nbsp;<br />
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
        </form>
    </body>
    </html>
      

  6.   

     protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Write(TextBox1.Text);
        }aaaa,bbbb,cccc,dddd 
      

  7.   

    首先把DropDownList的autopostback设置为true
    然后在DropDownList的SelectedIndexChanged事件中写处理代码:
    this.TextBoxName.Text = this.DropDownListName.SelectedValue就可以了。
      

  8.   

     if(document.getElementById("TextBox1").value=="")
                document.getElementById("TextBox1").value +=objddl.options[objddl.selectedIndex].value;
                else
                document.getElementById("TextBox1").value +=","+objddl.options[objddl.selectedIndex].value;