You must Sign In to post a response.
  • Category: ASP.NET

    Dropdown with comma separated values

    Hi,


    I'm using CheckBoxList to select multiple values for dropdown(MultiSelectDDL).
    I want to show the selected values in dropdown with comma separated values.
    Pls provide me solution.


    <asp:DropDownList ID="MultiSelectDDL"
    runat="server">
    <asp:ListItem Value="all">Select</asp:ListItem>
    </asp:DropDownList>
    <asp:Panel ID="PanelPopUp" runat="server" BackColor="Black" ForeColor="AliceBlue">
    <asp:CheckBoxList ID="CheckBoxList" runat="server"
    DataSourceID="SqlDataSource1" DataTextField="Department"
    DataValueField="Department" oninit="CheckBoxList_Init"
    onselectedindexchanged="CheckBoxList_SelectedIndexChanged"
    ontextchanged="CheckBoxList_TextChanged">
    </asp:CheckBoxList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:CMSConnectionMultipleDDL %>"
    SelectCommand="SELECT [Department] FROM [Department]"></asp:SqlDataSource>
    </asp:Panel>
  • #525689
    Hi

    You want the selected items from check box list should be added to drop down?

    Thanks
    Shekar.Y

  • #525695
    Yes.If I select Emp1 and Emp2 from check Box

    In drop down I should get value as :- Emp1,Emp2

  • #525820
    use query to combine that column with comma

    select coloumn1+','+column2+',' as data from tablename

  • #525873

    protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
    {
    DropDownList1.Items.Add(CheckBoxList1.SelectedItem.Text);
    }

    Nothing is Impossible... :)

    My Forum :http://www.dotnetobject.com


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.