I have two dropdownlists that are bound to the same datasource and I
have a couple of questions:
1) Because they are bound to the same datasource, I am assuming that
they only make 1 round trip to the DB server -- is that correct?
2) On a user's click of a button, one of the actions in the button
OnClick event is to set the selectedindex of the 2nd DDL to that of the
1st. I get a runtime error here that says that the given index is not
in the list of items. Is this because the button event is firing
before the listitems are populated? If so how do I get the list items
to populate 1st? Also the list items will probably not change in the
term of a user session, is there a way to prevent the page from
retreiving the listitems on each postback?
Here is my relevant code:
<asp:SqlDataSou rce ID="dsICD9" runat="server"
ConnectionStrin g="<%$...%>"
SelectCommand=" ...">
</asp:SqlDataSour ce>
<asp:DropDownLi st AppendDataBound Items="true" ID="ddl1"
runat="server" DataSourceID="d sICD9"
onkeypress="ret urn KeySortDropDown List_onkeypress (this,false)"
DataTextField=" description" DataValueField= "ICD9">
<asp:ListItem Selected="True" ></asp:ListItem>
</asp:DropDownLis t>
<asp:DropDownLi st AppendDataBound Items="true" ID="ddl2"
runat="server" DataSourceID="d sICD9"
onkeypress="ret urn KeySortDropDown List_onkeypress (this,false)"
DataTextField=" description" DataValueField= "ICD9">
<asp:ListItem Selected="True" ></asp:ListItem>
</asp:DropDownLis t>
Protected Sub AddCPT_Click(By Val sender As Object, ByVal e As
System.EventArg s)
...
ddl2.SelectedIn dex = ddl1.SelectedIn dex <-----Here's where I get
the runtime error
...
End Sub