This is a migrated thread and some comments may be shown as answers.

ComboBox with CheckBoxes - CheckedItems as multi-value parameter

1 Answer 120 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
GARY078
Top achievements
Rank 1
GARY078 asked on 02 Oct 2012, 06:55 PM
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.

1 Answer, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 08 Oct 2012, 08:47 AM
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.
Tags
ComboBox
Asked by
GARY078
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or