-1

I am having dropdownlist with some values. If i choose multiple items in dropdown it has to bind in textbox in the format of

ex:

'xxxx','xxxx','xxxx'

Please do the needful

Thanks

4

3 回答 3

0

我建议你服务器端服务器 .net 服务器端控制

<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox> 

客户端 HTML 控件

<select multiple="multiple">             
   <option value="value">text</option>
   <option value="value">text</option>            
</select>
于 2013-09-19T13:07:06.410 回答
0

我认为您不能在下拉列表中选择多个项目。让我们假设您的意思是列表框。您选择的索引更改事件函数必须类似于:

protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    for (int i = 0; i < ListBox1.Items.Count; i++)
    {
        if (ListBox1.Items[i].Selected)
        {
            TextBox1.Text =TextBox1.Text + "'" + ListBox1.Items[i].Text + "' ";
        }
    }
}

逗号更新:

protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    for (int i = 0; i < ListBox1.Items.Count; i++)
    {
        if (ListBox1.Items[i].Selected)
        {
             if (TextBox1.Text == "")
             {
                 TextBox1.Text = TextBox1.Text + "'" + ListBox1.Items[i].Text + "'";
             }
             else
             {
                 TextBox1.Text =TextBox1.Text + ",'" + ListBox1.Items[i].Text + "'";
             }
        }
    }
}
于 2013-09-19T10:56:03.293 回答
0

我不确定,我认为这可以帮助您满足您的要求

http://www.obout.com/combobox/aspnet_selection_multi.aspx

当您选择多个项目时,项目将完全按照您指定的格式显示在组合框中

于 2013-09-19T11:30:53.587 回答