Multiple SelectedValues i ListBox
Jeg har et web application project lavet på 2.0 frameworket, med et lille problem.Der er 5 kontroller på siden: ListBox1, Calendar_Start_Date, Calendar_Stop_Date, ListBox2,GridView_Activity_List
GridViewet bliver udfyldt afhængig af hvad der vælges i de 4 andre kontroller, og ListBoxene indeholder SelectionMode="Multiple".
Problemet er, at selv om jeg vælger flere ting i samme ListBox, er det kun det valgte element der står længst nede på listen, der bliver brugt.
Eksempel:
ListBox1: 1,2,3
ListBox2: a,b,c
Mulige resultater: 1a,1b,1c,2a,2b,2c,3a,3b,3c
Hvis jeg vælger 1; a og b, vil jeg så gerne se resultaterne 1a og 1b. Desværre kommer der kun 1b ud af det.
Nedenfor er koden til aspx siden.
Nogen der kan fortælle hvad jeg mangler?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Scout_Activity_Search.aspx.cs" Inherits="ScoutSystem.ScoutSystem_BasicModule.Scout_Activity_Search" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource_Activity_Type"
DataTextField="F_Dim_Detail_Custom_Text" DataValueField="F_Dim_Detail_Custom_ID"
SelectionMode="Multiple" AutoPostBack="True"></asp:ListBox>
<asp:SqlDataSource ID="SqlDataSource_Activity_Type" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" SelectCommand="SELECT [F_Dim_Detail_Custom_ID], [F_Dim_Detail_Custom_Text] FROM [T_Dim_Detail_Custom] WHERE ([F_Dim_Detail_Custom_Type_ID] = @F_Dim_Detail_Custom_Type_ID) ORDER BY [F_Dim_Detail_Custom_Order]">
<SelectParameters>
<asp:Parameter DefaultValue="6" Name="F_Dim_Detail_Custom_Type_ID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:Calendar ID="Calendar_Start_Date" runat="server">
</asp:Calendar>
<asp:Calendar ID="Calendar_Stop_Date" runat="server">
</asp:Calendar>
<asp:ListBox ID="ListBox2" runat="server" DataSourceID="SqlDataSource_Scout" DataTextField="F_Scout_Name" DataValueField="F_Scout_ID" SelectionMode="Multiple" AutoPostBack="True"></asp:ListBox>
<asp:SqlDataSource ID="SqlDataSource_Scout" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" SelectCommand="SELECT [F_Scout_ID], [F_Scout_Name] FROM [T_Scout]"></asp:SqlDataSource>
<br />
<asp:GridView ID="GridView_Activity_List" runat="server" AutoGenerateColumns="False" DataKeyNames="F_Scout_Activity_ID" DataSourceID="SqlDataSource_Activity_List" EmptyDataText="There is no data for the current search.">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="F_Scout_Activity_ID" HeaderText="F_Scout_Activity_ID"
InsertVisible="False" ReadOnly="True" SortExpression="F_Scout_Activity_ID" />
<asp:BoundField DataField="F_Scout_Activity_Scout_ID" HeaderText="F_Scout_Activity_Scout_ID"
SortExpression="F_Scout_Activity_Scout_ID" />
<asp:BoundField DataField="F_Scout_Activity_Date" HeaderText="F_Scout_Activity_Date"
SortExpression="F_Scout_Activity_Date" />
<asp:BoundField DataField="F_Scout_Activity_Dim_Detail_Custom_ID" HeaderText="F_Scout_Activity_Dim_Detail_Custom_ID"
SortExpression="F_Scout_Activity_Dim_Detail_Custom_ID" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource_Activity_List" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" SelectCommand="SELECT [F_Scout_Activity_ID], [F_Scout_Activity_Scout_ID], [F_Scout_Activity_Date], [F_Scout_Activity_Dim_Detail_Custom_ID] FROM [T_Scout_Activity] WHERE (([F_Scout_Activity_Scout_ID] = @F_Scout_Activity_Scout_ID) AND ([F_Scout_Activity_Date] <= @F_Scout_Activity_Date) AND ([F_Scout_Activity_Date] >= @F_Scout_Activity_Date2) AND ([F_Scout_Activity_Dim_Detail_Custom_ID] = @F_Scout_Activity_Dim_Detail_Custom_ID))">
<SelectParameters>
<asp:ControlParameter ControlID="ListBox2" Name="F_Scout_Activity_Scout_ID"
PropertyName="SelectedValue" Type="Int32" />
<asp:ControlParameter ControlID="Calendar_Stop_Date" Name="F_Scout_Activity_Date"
PropertyName="SelectedDate" Type="DateTime" />
<asp:ControlParameter ControlID="Calendar_Start_Date" Name="F_Scout_Activity_Date2"
PropertyName="SelectedDate" Type="DateTime" />
<asp:ControlParameter ControlID="ListBox1" Name="F_Scout_Activity_Dim_Detail_Custom_ID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>