-
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.
-
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()
-
...
do you have some code example for the step you gave.
10x.
-
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