user441521
user441521

Reputation: 6988

asp.net data binding with parameter where value is from another control

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.

Upvotes: 0

Views: 744

Answers (1)

Kaf
Kaf

Reputation: 33809

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>

Upvotes: 1

Related Questions