我有四个下拉列表,全部依赖于之前的下拉列表,使用ControlParameters和AutoPostBack =“true”,它们都完美无缺 - 除了最后一个。由于某种原因,第四个没有显示我的硬编码“--All--”项目,我需要这样,因此用户可以选择查看所有条目,或根据所选值限制条目。任何建议都非常感谢!
1(始终显示所有不同的值,加上“--All--”选项):
<!-- Division (gt_division) -->
<asp:DropDownList runat="server" ID="DDLDivision" DataSourceID="DSDivision" DataValueField="gt_division" DataTextField="gt_division" AppendDataBoundItems="true" AutoPostBack="true">
<asp:ListItem Text="--All--" Value="" />
</asp:DropDownList>
<asp:SqlDataSource ID="DSDivision" ConnectionString="<%$ ConnectionStrings:CDRConnectionString %>" runat="server" SelectCommand="select distinct gt_division from chg_dtl">
</asp:SqlDataSource>
2(工作正常,下拉列表显示'--All--',加上基于第一个下拉列表中选择的不同值(controlparameter gt_division):
<!-- Program (bill_area) -->
<asp:DropDownList runat="server" ID="DDLProgram" DataSourceID="DSProgram" DataValueField="bill_area" DataTextField="bill_area" AppendDataBoundItems="true" AutoPostBack="true">
<asp:ListItem Text="--All--" Value="" />
</asp:DropDownList>
<asp:SqlDataSource ID="DSProgram" ConnectionString="<%$ ConnectionStrings:CDRConnectionString %>" runat="server" SelectCommand="SELECT distinct bill_area FROM chg_dtl WHERE gt_division = @gt_division">
<SelectParameters>
<asp:ControlParameter Name="gt_division" ControlID="DDLDivision" PropertyName="SelectedValue"/>
</SelectParameters>
</asp:SqlDataSource>
3(同样正常,显示' - 全部 - '加上基于前两个下拉列表的值):
<!-- Location (pos_name) -->
<asp:DropDownList runat="server" ID="DDLLocation" DataSourceID="DSLocation" DataValueField="pos_name" DataTextField="pos_name" AppendDataBoundItems="true" AutoPostBack="true">
<asp:ListItem Text="--All--" Value="" />
</asp:DropDownList>
<asp:SqlDataSource ID="DSLocation" ConnectionString="<%$ ConnectionStrings:CDRConnectionString %>" runat="server" SelectCommand="SELECT distinct pos_name FROM chg_dtl WHERE gt_division = @gt_division and bill_area = @bill_area"
>
<SelectParameters>
<asp:ControlParameter Name="gt_division" ControlID="DDLDivision" PropertyName="SelectedValue" />
<asp:ControlParameter Name="bill_area" ControlID="DDLProgram" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
4(显示正确的不同值(基于之前的三个下拉列表),但在前一个下拉列表的回发中没有显示'--All--'选项。所以我选择Program,这个下拉列表填充使用正确的不同值,但是' - All--'缺失。我需要这个选项让用户可以选择查看所有内容,而不仅仅是单个下拉选项的结果。我可能会在后面的代码中执行某些操作,但我宁愿保持所有下拉菜单相同。):
<!-- Physician (BILLING_NAME) -->
<asp:DropDownList runat="server" ID="DDLPhysician" DataSourceID="DSPhysician" DataValueField="billing_prov_name" DataTextField="billing_name" AppendDataBoundItem="true" AutoPostBack="true">
<asp:ListItem Text="All" Value="" />
</asp:DropDownList>
<asp:SqlDataSource ID="DSPhysician" ConnectionString="<%$ ConnectionStrings:CDRConnectionString %>" runat="server"
SelectCommand="SELECT distinct billing_name
FROM chg_dtl
WHERE gt_division = @gt_division AND bill_area = @bill_area AND pos_name = @pos_name"
>
<SelectParameters>
<asp:ControlParameter Name="gt_division" ControlID="DDLDivision" PropertyName="SelectedValue" />
<asp:ControlParameter Name="bill_area" ControlID="DDLProgram" PropertyName="SelectedValue" />
<asp:ControlParameter Name="pos_name" ControlID="DDLLocation" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
答案 0 :(得分:0)
您在第4个下拉列表中有'AppendDataBoundItems'而不是'AppendDataBoundItems'