Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Wrong data in dropdownlist

Reply
Thread Tools

Wrong data in dropdownlist

 
 
Frederik Vanderhaeghe
Guest
Posts: n/a
 
      05-16-2006
Hi,

I want to get values out of the database into a dropdownlist, but when I run
my form, I get one value: 'system.data.datarow'

My code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not Page.IsPostBack Then

Dim strSQLJaar As String = "select distinct year(Datum) as jaar from
TBL_Stat_Sites"

connectie.Open()

Dim daJaar As New SqlClient.SqlDataAdapter(strSQLJaar, connectie)

daJaar.Fill(ds, "jaren")

ddlJaar.DataSource = ds.Tables("jaren")

ddlJaar.DataBind()

End If


End Sub


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9u?=
Guest
Posts: n/a
 
      05-16-2006
Hello

You'll need to set the DataTextField and DataValueFiend on the dropdownlist.

HTH.

Jon

"Frederik Vanderhaeghe" wrote:

> Hi,
>
> I want to get values out of the database into a dropdownlist, but when I run
> my form, I get one value: 'system.data.datarow'
>
> My code:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> If Not Page.IsPostBack Then
>
> Dim strSQLJaar As String = "select distinct year(Datum) as jaar from
> TBL_Stat_Sites"
>
> connectie.Open()
>
> Dim daJaar As New SqlClient.SqlDataAdapter(strSQLJaar, connectie)
>
> daJaar.Fill(ds, "jaren")
>
> ddlJaar.DataSource = ds.Tables("jaren")
>
> ddlJaar.DataBind()
>
> End If
>
>
> End Sub
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
get selected data from dropdownlist in data grid munther ASP .Net 2 09-12-2007 11:26 AM
GridView: Filter DropDownList for another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-29-2005 07:44 AM
GridView: Filtr DropDownList from another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-23-2005 01:31 PM
databinding a Dropdownlist to another dropdownlist tshad ASP .Net 8 10-19-2005 10:00 PM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM



Advertisments