473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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 1217
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: CJ | last post by:
Hey! I have 3 dropdownlist depending on eash other. It's a hierarchy. The first dropdownlist generate the second and the second generate the third. The first i have a sql query for, so that...
1
by: Harry | last post by:
Hi, Just seeing if anyone can help me with a problem I am having with drop down lists. - I have a asp:dropdownlist that gets its values from a database. - The user then selects a value then...
2
by: Cortvriend Andy | last post by:
hi i'm filling an dropdownlist with data from sql server now i want to validate if a selection have been made the problem is that the validator never shows up i think he always says that...
4
by: Yahya Saad | last post by:
Dear All, I have an ASP.Net webform that includes a DropDownList (bound to a dataview including 6000 records) and a textbox that is updated according to the selection of an event at the...
3
by: tshad | last post by:
I am trying to fill my DropDownList (actually a few of them) with data from my sql table. I am calling Stored procedures for all of them. I would like to use the first line as a place holder...
19
by: Bernie Yaeger | last post by:
Everyone misses the point on this - what we need is a combobox autocomplete that is a dropdownlist only. When in dropdown mode, you can enter text - making that autocomplete is trivial. But when...
1
by: Miguel Dias Moura | last post by:
Hello, I have two questions concerning Asp:DropDownList 1. How to fill a DropDownList from runtime and set its default item? 2. How do use a DropDownList in each datagrid record? All...
0
by: Learner | last post by:
Hello, We have a need to customize the CreateUserWizard and we put a DropDownList control in there. And we are filling that DropDownControl ( _drplDealers) in the page_load event of the code...
4
by: ITCraze | last post by:
Hello everyone, I have three tables CompanyMst ,BranchMst and DeptMst. CompanyMst contains: CompanyId(Primary Key) ,CompanyName. BranchMst contains: CompanyId(Foreign...
1
by: coolnavjot31 | last post by:
I have Gridview with Template Field.And I Put Dropdownlist at footer row of gridview. but when i insert the value from a database table in dropdownlist , than it generate error. for filling value ,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.