I have created 2 dropdownlists that are binded to a SQL DB and then pulling up a GridView. But, more specifically is there a way to have 3 user picked boxes and then have a Gridview show up? I would like to have a quick efficient way to do this without problems. I created the first 2 DDLs with autopostback and not working properly. any suggestions?
<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' /> <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' /> <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>
You can turn off AutoPostBack for all the DropDownLists, and add a Button called Lookup with something like the following in the Lookup Button_Click event:
Your select command would need to be updated to include the additional criteria in your DataSource: