Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to bind two dropdown controls with the same query result

Status
Not open for further replies.

taree

Technical User
May 31, 2008
316
US
Will it possible to bind the same query result to two dropdown controls like this? thank you
Code:
 Dim strStringBuilder As StringBuilder
        strStringBuilder = New StringBuilder
        With strStringBuilder
            .Append("SELECT TM from tbTM ")
        End With

        Dim cmdMemos As OleDbCommand = New OleDbCommand
        cmdMemos.Connection = MyTechMemoConn
        cmdMemos.CommandType = CommandType.Text
        cmdMemos.CommandText = strStringBuilder.ToString
        Dim adMemoStatus As New OleDbDataAdapter(cmdMemos)

        Dim dsMemos As New DataSet

        adMemoStatus.Fill(dsMemos, "MemoStatus")
        drpSuperSTM.DataSource = dsMemos
        drpSuperSTM.DataTextField = "TM"
        drpSuperSTM.DataValueField = "TM"
        drpTM.DataTextField = "TM"
        drpTM.DataValueField = "TM"
        drpSuperSTM.DataBind()
        drpTM.DataBind()
 
yes, load the data into a datatable. then set each dropdownlist's DataSource to the dataTable.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thank you Jason. I am curious though why did not the above code work for me?
 
I figured it out. I was missing
drpTM.DataSource = dsMemos for second dropdown control.

thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top