Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
The idea here is to allow users to set a pre-define search criteria for data retrieval from a MS SQ L Database. A submit button will be added later to search another database that holds the data to be retrieved once completed.
This is not the issue. Please see file/example below.

The Problem
With the file/example below, a:
1. User can select a Supplier of interest from the Supplier/DDL.
2. User will then select a Category of interest from the Categories/Checkboxes.
3. After those selections are made, the Product/DDL will populate/update
based on user’s Supplier/DDL and Categories/Checkboxes selections.
This works OK - if you want the user to select only one item from the Categories/Checkboxes which will populate/update the Product/DDL based on that one item selected.
However, what if a user wants to select more than one Category to see more Products at the same time in the Products/DDL? I would like to see a working model code/solution that will populate/update the Product/DDL
when a user makes multiple Categories selections.
Users should be able to make a single selection from the Supplier/DDL and a single or multiple selections from the Category/Checkboxes.
As such, the Product/DDL should populate/update based on those selections updating selected/un-selected items accordingly. Thank you.

SupplierDDLLoad:
1 Abstract Accent
2 Berma Expo
3 Carter Furniture
4 Dream Inc
5 Elk Design
CategoriesCheckboxes:
1 Bedroom
2 Den
3 Dining
4 Entertainment
5 Kitchen
6 Living
7 Office
8 Patio
ProductDDLLoad?:
Based on Supplier and Category Selections.


Table Items: MS SQ L Database;
This is a sample used only to set pre-define search criteria for user’s data retrieval.

SupID SupplierName CatID CategoryName ProID ProductName SupID CatID
1 Abstract Accent 1 Kitchen 1 Jacobean 1 1
2 Berma Expo 2 Dining 2 American 1 4
3 Carter Furniture 3 Bedroom 3 WilMar 1 2
4 Dream Inc 4 Den 4 Queen A 1 5
5 Elk Designs 5 Living 5 Colonial 1 3
NULL NULL 6 Entertainment 6 Georgian 2 8
7 Office 7 Dutch 2 2
8 Patio 8 Chippendale 2 4
NULL NULL 9 Robert Adam 3 6
10 Hepplewhite 3 4
11 Federal 3 7
12 Sheraton 4 8
13 DunPhyfe 4 5
14 Empire 4 5
15 Shaker 4 6
16 Victorian 4 3
17 ArtsCraft 5 6
18 Art Noveau 5 3
19 Scandinavian 5 4
20 Contemporary 5 7
NULL :) NULL NULL
XML
<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="CategoryName"
DataValueField="CatID">
    <asp:ListItem>Bedroom</asp:ListItem>
    <asp:ListItem>Den</asp:ListItem>
    <asp:ListItem>Dining</asp:ListItem>
    <asp:ListItem>Entertainment</asp:ListItem>
    <asp:ListItem>Kitchen</asp:ListItem>
    <asp:ListItem>Living</asp:ListItem>
    <asp:ListItem>Office</asp:ListItem>
    <asp:ListItem>Patio</asp:ListItem>
</asp:CheckBoxList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:furn %>"
    SelectCommand="SELECT DISTINCT [CatID], [CategoryName] FROM [Category] ORDER BY [CategoryName]">
</asp:SqlDataSource>
</td>
<td class="style2">
<span class="style3"><span class="style4">Product:</span><br />
</span><br />
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource3" DataTextField="ProductName"
DataValueField="ProID" onselectedindexchanged="DropDownList2_SelectedIndexChanged">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
    ConnectionString="<%$ ConnectionStrings:furn %>"
    SelectCommand="SELECT DISTINCT [ProID], [ProductName] FROM [Product] WHERE (([SupID] = @SupID) AND ([CatID] = @CatID))"
    onselecting="SqlDataSource3_Selecting">
    <SelectParameters>
        <asp:ControlParameter ControlID="DropDownList1" Name="SupID"
            PropertyName="SelectedValue" Type="Int32" />
        <asp:ControlParameter ControlID="CheckBoxList1" Name="CatID"
            PropertyName="SelectedValue" Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>
Posted
Updated 6-Feb-11 18:39pm
v3
Comments
Sunasara Imdadhusen 7-Feb-11 0:14am    
No body are interested to read whole story instead of your problem!!

1 solution

I do not have a code snippet for this.I would suggest you to use a GridView Control where you can show multiple product dropdowns for each supplier/category selection in different rows.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900