0

I have a normal asp.net website (not MVC). I have a dropdown control and a listbox. I have the listbox in an updatepanel control. The dropdown is bound to a table. When the user selects from the dropdown I want the listbox to update it's data based on the value in the dropdown.

I have the trigger setup to the dropdowns SelectedIndexChanged event. I guess what I don't know is how I can bind the listbox with the table I want to use where it has a parameter that gets filled in by the selection value of the dropdown. Is there a way to do this without codebehind and using a SqlDataSource control for the listbox? It's not the end of the world to get into code but just curious if this can be setup somehow without codebehind.

1 Answer 1

1

What you are looking for is a ControlParameter:

<asp:SqlDataSource 
    //...Your DataSource properties
   <SelectParameters>
       //..Control Parameter adjust as required
       <asp:ControlParameter Name="ParameterName_As_In_Sp_Or_Query" 
                             DbType="Int16" DefaultValue="0" 
                             ControlID="ddlYourDropDown"/>
   </SelectParameters>
</asp:SqlDataSource>
Sign up to request clarification or add additional context in comments.

1 Comment

I noticed that as soon as I put in a parameter ":id" in the query via the wizard of the SqlDataSource it took me to another page to define these. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.