0

Hi,
I am creating a page that has two dropdowns. One drop down needs to change dynamically depending on the selection made in the other.
So Dropdown2 values depend on dropdown1 selection. To do this I am trying to add code to the Dropdown1_SelectedIndexChanged event.
The data comes in from Access. Both dropdowns are databound using asp accessdatasource declarative tags.
So when I handle the _SelectedIndexChanged event do I need to programmatically create another accessdatasource object and start all over? Or can I use the accessdatasource object that was created declaratively?

Thanks.

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by serkan sendur
0

Nevermind. I figured it out. I will post the solution soon.

0

Here's the code as promised:

Code-behind:

Protected Sub <dropdownlist1name>_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles <dropdownlist1name>.SelectedIndexChanged
        Dim <variable> As String
        <variable> = <dropdownlist2accessdatasource>.SelectParameters(0).Name()
        <dropdownlist2accessdatasource>.SelectCommand = "select * from a where b = <variable> "

Inline -code:

<asp:AccessDataSource 
	runat="server" 
	ID="dropdownlist2datasource" 
	DataFile="accessdb.mdb" 
	SelectCommand="SELECT  * FROM a where b= @variable">
	 <SelectParameters>
      <asp:ControlParameter 
      ControlID="dropdownlist1" 
      Name=<varible> 
      PropertyName="SelectedValue" 
      Type="String" />
   </SelectParameters>

In addition to this, set AutoPostBack="True" on the dropdownlist that triggers the second dropdown.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.