|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
dropdownlist not filling up?
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 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) Joris De Groote wrote:
> Hi, There was no way for you to know it, but this is a classic asp newsgroup.> > 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) 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: > You can't databind and manually add items to the list. It's one or the> 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??? > other. I suggest using a union query to add the "selecteer" option to the list that comes from the database: > Change this statement to:> ---Code--- > If Not Page.IsPostBack Then > > InlezenConfig() > > Dim strsqlDocType As String = "select distinct type from > TBL_Bestanden_Zoeken" > 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. |
|||||||||||||||||||||||