ComboBox with CheckBoxes - CheckedItems as multi-value parameter

2 posts, 0 answers
  1. GARY078
    GARY078 avatar
    11 posts
    Member since:
    Jun 2012

    Posted 02 Oct 2012 Link to this post

    I have multiple comboBoxes all with checkboxes. What I want to do is pass the checkedItems (multiple) of a comboBox as a parameter value for a stored procedure.

    The way the stored procedure is built, having a separator of "+" would work when more than one checkbox is checked. (I have Display All Input set to true). However the separator by default is ",".

    Is there any way of changing the separator that appears when more than one checkbox is checked within a comboBox?

    If not, how do I append a "+" sign onto the end of each item when it is checked, basically it would be to convert the checkedItems to a "+" delimited list and send them as parameters that way.

    cmd.Parameter.AddWithValue("@ID_SYSTEM", ID_SYSTEM);

    I want to be able to pass more than just one instance of @ID_SYSTEM as a parameter value for a stored procedure.
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 08 Oct 2012 Link to this post

    Hi GARY,


    You can pass the checked items as a parameter to SQLDataSource select command (or stored procedure) from code-behind:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            if (this.NamesDDL.CheckedItems.Count > 0)
            {
                gridSource.SelectCommand = "SELECT ProductID, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock, Discontinued FROM [Northwind].[dbo].[Products] WHERE SupplierID in (" + GetValues() + ")";
                this.OrdersGrid.Rebind();
            }
             
        }
        else
        {
            gridSource.SelectCommand = "SELECT ProductID, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock, Discontinued FROM [Northwind].[dbo].[Products]";
            this.OrdersGrid.Rebind();
        }
     
    }


    Regarding your second question - I am afraid that currently there is no option to change the checked items texts delimiter.

    I prepared a basic sample for you - please download it and give it a try.

    Regards,
    Kalina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top