本文介绍了在DDL中显示单个/多个复选框选择结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处的想法是允许用户设置预定义搜索条件,以便从MS SQ L数据库中检索数据.稍后将添加一个提交按钮,以搜索另一个数据库,该数据库包含完成后要检索的数据.
这不是问题.请参见下面的文件/示例.

问题
在下面的文件/示例中,a:
1.用户可以从供应商/DDL中选择感兴趣的供应商.
2.然后,用户将从类别/复选框中选择一个感兴趣的类别.
3.做出选择之后,产品/DDL将填充/更新
根据用户的供应商/DDL和类别/复选框选择.
这行得通-如果您希望用户仅从类别/复选框"中选择一项,该类别/复选框将基于所选的一项来填充/更新产品/DDL.
但是,如果用户希望选择多个类别来同时在产品/DDL"中查看更多产品,该怎么办?我想看到一个有效的模型代码/解决方案,它将填充/更新产品/DDL
当用户进行多个类别选择时.
用户应该能够从供应商/DDL中进行单一选择,并能够从类别/复选框中进行单一或多项选择.
这样,产品/DDL应该基于那些选择来填充/更新,从而相应地更新选定/未选定的项目.谢谢.

SupplierDDLLoad:
1抽象口音
2 Berma Expo
3卡特家具
4 Dream Inc
5麋鹿设计
类别复选框:
1间卧室
2窝
3用餐
4娱乐
5厨房
6生活
7办公室
8天井
ProductDDLLoad ?:
基于供应商和类别选择.


表项目:MS SQ L数据库;
这是一个示例,仅用于为用户的数据检索设置预定义搜索条件.

SupID供应商名称CatID类别名称ProID产品名称SupID CatID
1抽象口音1厨房1 Jacobean 1 1
2 Berma Expo 2餐饮2 American 1 4
3 Carter家具3卧室3 WilMar 1 2
4 Dream Inc 4巢穴4 Queen A 1 5
5麋鹿设计5居住5殖民地1 3
NULL NULL 6娱乐节目6格鲁吉亚语2 8
7 Office 7荷兰语2 2
8天井8 Chippendale 2 4
NULL NULL 9罗伯特·亚当3 6
10 Hepplewhite 3 4
11联邦3 7
12喜来登4 8
13 DunPhyfe 4 5
14帝国4 5
15摇床4 6
16维多利亚时代4 3
17 ArtsCraft 5 6
18 Art Noveau 5 3
19斯堪的纳维亚人5 4
20当代5 7
NULL :) NULL NULL

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

<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>

推荐答案




这篇关于在DDL中显示单个/多个复选框选择结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 06:54
查看更多