2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by SheSaidImaPregy
0

You can do this by a postback:

<!-- on your first dropdownlist have an onselected code -->
<asp:DropDownList id="ColorList" AutoPostBack="True" OnSelectedIndexChanged="ddlColorListChange" runat="server">

<!-- now in the script at the top of the page create a sub -->
<script language="vb" runat="server">
Sub ddlColorListChange(ByVal S As Object, ByVal E As EventArgs)
  Dim strSelectedItem As String = ddlColorListChange.SelectedIndex.Value
  Dim conn As New OdbcConnection( connstringhere )
  Dim cmdSelect As New OdbcCommand( "SELECT * FROM table WHERE blank=?", conn )
  conn.Open()
  Dim dtrReader As OdbcDataReader = cmdSelect.ExecuteReader()
  if dtrReader.HasRows then
    ddlSecondList.DataSource = dtrReader
    ddlSecondList.DataTextField = "nameofcolumn"
    ddlSecondList.DataValueField = "nameofcolumn"
    ddlSecondList.DataBind()

    'set a selected item if you wish.
    ddlSecondList.SelectedIndex = 0
  end if
  dtrReader.Close()
  conn.Close()
End Sub
</script>
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.