ASP.net表单/下拉列表帮助

ASP.net表单/下拉列表帮助,asp.net,Asp.net,我创建了两个dropdownlists,它们绑定到一个sqldb,然后启动一个GridView。但是,更具体地说,有没有一种方法可以让用户选择3个框,然后显示Gridview?我想有一个快速有效的方法来做到这一点没有问题。我使用autopostback创建了前2个DDL,但工作不正常。有什么建议吗 <asp:Label ID="CustomerNumberLabel" runat="server" Text="Customer Number " Width="125px">&

我创建了两个dropdownlists,它们绑定到一个sqldb,然后启动一个GridView。但是,更具体地说,有没有一种方法可以让用户选择3个框,然后显示Gridview?我想有一个快速有效的方法来做到这一点没有问题。我使用autopostback创建了前2个DDL,但工作不正常。有什么建议吗

    <asp:Label ID="CustomerNumberLabel" runat="server" Text="Customer Number " Width="125px"></asp:Label>
    <asp:DropDownList ID="CustomerNumber" runat="server" AutoPostBack="True" 
        DataSourceID="ADDRDataSource" DataTextField="SACSNO" 
        DataValueField="SACSNO" AppendDataBoundItems="True">
        <asp:ListItem Text="Select a Customer" Value="" Selected="True" />
    </asp:DropDownList><br />
    <asp:SqlDataSource ID="ADDRDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:iSeriesHistoryConnectionString %>" 
        SelectCommand="SELECT [SACSNO] FROM [ADDR] WHERE ([SARP#1] = @column1)">
        <SelectParameters>
            <asp:SessionParameter Name="column1" SessionField="userName" Type="Decimal" />
        </SelectParameters>
    </asp:SqlDataSource>
     <asp:Label ID="ShipToNumberLabel" runat="server" Text="Ship-to Location " Width="125px"></asp:Label>   
    <asp:DropDownList ID="ShipToNumber" runat="server" 
        DataSourceID="ADDRShipToNumberDataSource" DataTextField="SASHNM" 
        DataValueField="SASHNM" AutoPostBack="True">
        <asp:ListItem Text="Select Ship-To Location" Value="" Selected="True" />
    </asp:DropDownList>
    <asp:SqlDataSource ID="ADDRShipToNumberDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:iSeriesHistoryConnectionString %>" 
        SelectCommand="SELECT [SASHNM], [SASAD1], [SASAD2], [SASCTY], [SACSNO], [SASHST], [SASZIP] FROM [ADDR] WHERE ([SACSNO] = @SACSNO)">
        <SelectParameters>
            <asp:ControlParameter ControlID="CustomerNumber" Name="SACSNO" 
                PropertyName="SelectedValue" Type="Decimal" />
        </SelectParameters>
    </asp:SqlDataSource>
   <br /><br />
    <asp:FormView ID="FormView1" runat="server" 
        DataSourceID="ADDRShippingDataSource" Width="400px">
        <EditItemTemplate>
            SACSNO:
            <asp:TextBox ID="SACSNOTextBox" runat="server" Text='<%# Bind("SACSNO") %>' />
            <br />
            SASHNM:
            <asp:TextBox ID="SASHNMTextBox" runat="server" Text='<%# Bind("SASHNM") %>' />
            <br />
            SASAD1:
            <asp:TextBox ID="SASAD1TextBox" runat="server" Text='<%# Bind("SASAD1") %>' />
            <br />
            SASAD2:
            <asp:TextBox ID="SASAD2TextBox" runat="server" Text='<%# Bind("SASAD2") %>' />
            <br />
            SASCTY:
            <asp:TextBox ID="SASCTYTextBox" runat="server" Text='<%# Bind("SASCTY") %>' />
            <br />
            SASHST:
            <asp:TextBox ID="SASHSTTextBox" runat="server" Text='<%# Bind("SASHST") %>' />
            <br />
            SASZIP:
            <asp:TextBox ID="SASZIPTextBox" runat="server" Text='<%# Bind("SASZIP") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <InsertItemTemplate>
            SACSNO:
            <asp:TextBox ID="SACSNOTextBox" runat="server" Text='<%# Bind("SACSNO") %>' />
            <br />
            SASHNM:
            <asp:TextBox ID="SASHNMTextBox" runat="server" Text='<%# Bind("SASHNM") %>' />
            <br />
            SASAD1:
            <asp:TextBox ID="SASAD1TextBox" runat="server" Text='<%# Bind("SASAD1") %>' />
            <br />
            SASAD2:
            <asp:TextBox ID="SASAD2TextBox" runat="server" Text='<%# Bind("SASAD2") %>' />
            <br />
            SASCTY:
            <asp:TextBox ID="SASCTYTextBox" runat="server" Text='<%# Bind("SASCTY") %>' />
            <br />
            SASHST:
            <asp:TextBox ID="SASHSTTextBox" runat="server" Text='<%# Bind("SASHST") %>' />
            <br />
            SASZIP:
            <asp:TextBox ID="SASZIPTextBox" runat="server" Text='<%# Bind("SASZIP") %>' />
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </InsertItemTemplate>
        <ItemTemplate>
            Customer Detail<br />
            <br />
            <table class="style1" width="35px">
                <tr>
                    <td class="style2" align="center" >
                        Address Line 1</td>
                    <td class="style3" align="center" >
                        <asp:Label ID="SASAD1Label" runat="server" Text='<%# Bind("SASAD1") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="style2" align="center" >
                        Address Line 2</td>
                    <td class="style3" align="center" >
                        <asp:Label ID="SASAD2Label" runat="server" Text='<%# Bind("SASAD2") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="style2" align="center">
                        City</td>
                    <td class="style3" align="center" >
                        <asp:Label ID="SASCTYLabel" runat="server" Text='<%# Bind("SASCTY") %>' />
                    </td>
                </tr>
                <tr>
                    <td align="center" class="style2">
                        State</td>
                    <td class="style3" align="center" >
                        <asp:Label ID="SASHSTLabel" runat="server" Text='<%# Bind("SASHST") %>' />
                    </td>
                </tr>
                <tr>
                    <td align="center" class="style2">
                        Zip</td>
                    <td class="style3" align="center" >
                        <asp:Label ID="SASZIPLabel" runat="server" Text='<%# Bind("SASZIP") %>' />
                    </td>
                </tr>
            </table>
            <br />
        </ItemTemplate>
    </asp:FormView>
    <asp:SqlDataSource ID="ADDRShippingDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:iSeriesHistoryConnectionString %>" 
        SelectCommand="SELECT [SACSNO], [SASHNM], [SASAD1], [SASAD2], [SASCTY], [SASHST], [SASZIP] FROM [ADDR] WHERE ([SASHNM] = @SASHNM)">
        <SelectParameters>
            <asp:ControlParameter ControlID="ShipToNumber" Name="SASHNM" 
                PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>

您可以为所有DropDownList关闭AutoPostBack,并在Lookup Button_Click事件中添加一个名为Lookup的按钮,类似于以下内容:

ADDRShippingDataSource.SelectParameters.Clear()

If ShipToNumber.SelectedValue <> "" Then
    ADDRShippingDataSource.SelectParameters.Add("SASHNM", ShipToNumber.SelectedValue)
End If

If CustomerNumber.SelectedValue <> "" Then
    ADDRShippingDataSource.SelectParameters.Add("SACSNO", CustomerNumber.SelectedValue)
End If

ADDRShippingDataSource.DataBind()
SELECT [SACSNO], [SASHNM], [SASAD1], [SASAD2], [SASCTY], [SASHST], [SASZIP] FROM [ADDR] WHERE (@SASHNM IS NULL OR [SASHNM] = @SASHNM) OR (@SACSNO IS NULL OR [SACSNO] = @SACSNO)