Wrong data in dropdownlist

Discussion in 'ASP .Net' started by Frederik Vanderhaeghe, May 16, 2006.

  1. 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
    Frederik Vanderhaeghe, May 16, 2006
    #1
    1. Advertising

  2. 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
    >
    >
    >
    =?Utf-8?B?Sm9u?=, May 16, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rui Macdonald
    Replies:
    2
    Views:
    817
    Brock Allen
    Apr 18, 2005
  2. mr2_93
    Replies:
    1
    Views:
    3,581
    mr2_93
    Oct 2, 2005
  3. sam
    Replies:
    15
    Views:
    835
    Russell
    Mar 13, 2006
  4. Matthew
    Replies:
    7
    Views:
    651
    Priscilla Walmsley
    Jan 7, 2005
  5. shapper
    Replies:
    2
    Views:
    20,717
    Altaf
    Aug 22, 2009
Loading...

Share This Page