dropdownlist not filling up?

J

Joris De Groote

Hi,

I have a dropdownlist that contains should contain several values from the
database, I fill it up in de page_load() with this code (at the end of the
message)

The code also adds a standard value, 'Selecteer een type' that should be
added at the beginning of the list. The problem now is that when i start my
application only the value 'Selecteer uw type' is in the dropdownlist, but
the other values from the database should also be in it. How can i fix
this???

Thanks
Joris


---Code---
If Not Page.IsPostBack Then

InlezenConfig()

Dim strsqlDocType As String = "select distinct type from
TBL_Bestanden_Zoeken"

Dim da As New SqlClient.SqlDataAdapter(strsqlDocType, connectie)

Try

connectie.Open()

da.Fill(ds, "doctype")

ddlDocType.DataSource = ds.Tables("doctype")

ddlDocType.DataBind()

Catch ex As Exception

Finally

connectie.Close()

ddlDocType.Items.Insert(0, "Selecteer een type")

ddlDocType.SelectedIndex = 0

End Try

End If

lblZoeken.Visible = False

dtgZoekResultaten.Visible = True
 
E

Evertjan.

Joris De Groote wrote on 18 apr 2006 in
microsoft.public.inetserver.asp.general:
Dim strsqlDocType As String =

This is not classic ASP, where this NG is about.

Could be VB or asp.net, but those have other NG's

Probeer het daar eens, Joris.
 
B

Bob Barrows [MVP]

Joris said:
Hi,

I have a dropdownlist that contains should contain several values
from the database, I fill it up in de page_load() with this code (at
the end of the message)

There was no way for you to know it, but this is a classic asp newsgroup.
ASP.Net is a different technology from classic ASP.
While you may be lucky enough to find a dotnet-savvy person here who can
answer your question, you can eliminate the luck factor by posting your
question to a newsgroup where the dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.

But read on:
The code also adds a standard value, 'Selecteer een type' that should
be added at the beginning of the list. The problem now is that when i
start my application only the value 'Selecteer uw type' is in the
dropdownlist, but the other values from the database should also be
in it. How can i fix this???
You can't databind and manually add items to the list. It's one or the
other. I suggest using a union query to add the "selecteer" option to the
list that comes from the database:
---Code---
If Not Page.IsPostBack Then

InlezenConfig()

Dim strsqlDocType As String = "select distinct type from
TBL_Bestanden_Zoeken"

Change this statement to:

Dim strsqlDocType As String = "select type from (" & _
"select 0 as src,'Selecteer een type' as type union all " & _
"select distinct 1,type from TBL_Bestanden_Zoeken) q" & _
" order by src, type"


HTH,
Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top