|
-
Aug 6th, 2002, 02:52 AM
#1
Thread Starter
Lively Member
dropdownlist problem
Hi !
I have a real problam with dropdownlist.
I need to add a data selected from Database into the dropdownlist.
can someone please send me an example of how i can do such.
to make things short, how can I add data from recordset to a dropdwon list .
thanks.
-
Aug 6th, 2002, 03:36 AM
#2
Fanatic Member
set the dropdownlist.datasource to ur dataSet
set the dropdownlist.datamember to the table name in ur recordset
set the dropdownlist.datatextfield to the field which will be the text to display for an option in the list
set the dropdownlist.datavaluefield to the field which will hold the VALUE for each option in ur list
then execute dropdownlist.databind()
-
Aug 6th, 2002, 03:37 AM
#3
Thread Starter
Lively Member
...
do you have some code example for the step you gave.
10x.
-
Aug 6th, 2002, 05:47 AM
#4
Fanatic Member
Code:
<script language="WHAT DO I PUT HERE FOR VISUAL BASIC!?">
sub BindComps()
dim cnOzSite as oleDbConnection
dim adOzSite as oledbDataAdapter
dim dsComps as new DataSet
dim dsDivs as new Dataset
dim connStr, sql as string
dim TMPAREA as Integer
TMPAREA = 1
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\OzSite.mdb"
sql="SELECT Name, CompID FROM Competition WHERE AreaID = " & TMPAREA & ";"
cnOzSite = new oledbConnection(connStr)
cnOzSite.open
adOzSite = new oledbDataAdapter(sql, cnOzSite)
adOzSite.fill(dsComps, "dtComps")
ddlComps.datasource = dscomps
ddlComps.datamember="dtComps"
ddlcomps.datatextfield = "Name"
ddlcomps.datavaluefield = "CompID"
ddlcomps.databind()
ddlComps.selectedindex = 0
bindDivs()
end sub
</script>
Thats what i had.
It connects to an Access Database
Last edited by SkiNLaB; Aug 6th, 2002 at 05:51 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|