Solved

How to set SelectedItem in a DataBound Control?

Posted on 2000-05-05
8
1,205 Views
Last Modified: 2010-08-05
Hi,
I have multiple DataList & DataCombo controls.  I would like to be able to programmatically set which item in the DataList or DataCombo is selected as a default based on input from a textbox.  It seems like it should be a simple thing to do.  However, I can't figure out how to do it.  Any help would be greatly appreciated.
Thanks
 
 
0
Comment
Question by:lkath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2780617
Use the SelectedItem property.

0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2780665
Nevermind.  I realized, too late, that you wanted to SET and not READ.
0
 

Author Comment

by:lkath
ID: 2780718
I thought that seemed the way to go.  However, I can't get it to work.  I have tried various variations such as:
  Set DataCombo1.SelectedItem = 3
or
  Set DataCombo1.SelectedItem.Text = adodcRS1.recordset!RS1Descpription

I've gotten errors with everything combination I have tried.

0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 43

Expert Comment

by:TimCottee
ID: 2780759
You need to move to the appropriate record in the underlying recordset and then refresh the datacombo.

Private Sub Command1_Click()
    Adodc1.Recordset.Find "ProductName = '" & Text1.Text & "'"
    DataCombo1.Refresh
End Sub

This example sets the selected item of the datacombo1 to the value of the text1.text property. Where the datacombo is bound to the ADODC1 data control.

0
 
LVL 14

Expert Comment

by:wsh2
ID: 2780770
Set adodcRS1.recordset.bookmark = DataCombo1.SelectedItem
0
 
LVL 3

Expert Comment

by:SirNick
ID: 2782326
Try

DataList.text = "the 1 u want"
0
 

Accepted Solution

by:
digimp earned 50 total points
ID: 2783981
after a datalist or a datacombo is linked to a database simply write

datacombo1= text1.text

0
 

Author Comment

by:lkath
ID: 2788284
Thank You All!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 5 hours left to enroll

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question