Solved

How to set SelectedItem in a DataBound Control?

Posted on 2000-05-05
8
1,120 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
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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now