469,271 Members | 1,484 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

dropdownlist not filling up?

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
Apr 18 '06 #1
2 1144
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 18 '06 #2
Joris De Groote wrote:
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
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Apr 18 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by CJ | last post: by
2 posts views Thread by Cortvriend Andy | last post: by
4 posts views Thread by Yahya Saad | last post: by
3 posts views Thread by tshad | last post: by
19 posts views Thread by Bernie Yaeger | last post: by
1 post views Thread by Miguel Dias Moura | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.