Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Drop down list not displaying items

Drop down list not displaying items

Scheduled Pinned Locked Moved Visual Basic
csharpdesignhelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brendan Vogt
    wrote on last edited by
    #1

    Hi, I am working with VB.NET on .NET 1.1, and I am not too familiar with it. When I add a drop down list to the .aspx page, it creates the following code in the page behind: Protected WithEvents ddlID As System.Web.UI.WebControls.DropDownList Now I want to go and populate this drop down in a method like this: ddlID = Me.CreateDropDownListForFileFields(columns) columns are the columns from a dataset and the function CreateDropDownListForFileFields creates items for all the columns and returns a drop down list. ..but ddlID does not display anything. Why is this? Please can some help? Regards ma se

    P 1 Reply Last reply
    0
    • B Brendan Vogt

      Hi, I am working with VB.NET on .NET 1.1, and I am not too familiar with it. When I add a drop down list to the .aspx page, it creates the following code in the page behind: Protected WithEvents ddlID As System.Web.UI.WebControls.DropDownList Now I want to go and populate this drop down in a method like this: ddlID = Me.CreateDropDownListForFileFields(columns) columns are the columns from a dataset and the function CreateDropDownListForFileFields creates items for all the columns and returns a drop down list. ..but ddlID does not display anything. Why is this? Please can some help? Regards ma se

      P Offline
      P Offline
      PrakashBhaskar
      wrote on last edited by
      #2

      u have to specify the datasource, do databind, specify datavalue and datatext field ddlist.DataSource = dataset1.Tables(0) ddlist.DataBind() ddlist.DataValueField = "column name" ddlist.DataTextField = "column name"

      Thanks Warm Regards Prakash-B

      B 1 Reply Last reply
      0
      • P PrakashBhaskar

        u have to specify the datasource, do databind, specify datavalue and datatext field ddlist.DataSource = dataset1.Tables(0) ddlist.DataBind() ddlist.DataValueField = "column name" ddlist.DataTextField = "column name"

        Thanks Warm Regards Prakash-B

        B Offline
        B Offline
        Brendan Vogt
        wrote on last edited by
        #3

        You don't understand!! I have the following piece of code: Protected WithEvents ddlID As System.Web.UI.WebControls.DropDownList In a method where I try to populate this drop down list: ddlID = Me.CreateDropDownListForFileFields(columns) CreateDropDownListForFileFields looks like this: Private Function CreateDropDownListForFileFields(ByVal columns As DataColumnCollection) As DropDownList Dim ddl As New DropDownList Dim column As DataColumn For Each column In columns ddl.Items.Add(New ListItem(column.ColumnName, column.ColumnName)) Next ddl.Items.Insert(0, New ListItem("Please select...", String.Empty)) ' Return Return ddl End Function Please see if you can help me know. Regards ma se

        D 1 Reply Last reply
        0
        • B Brendan Vogt

          You don't understand!! I have the following piece of code: Protected WithEvents ddlID As System.Web.UI.WebControls.DropDownList In a method where I try to populate this drop down list: ddlID = Me.CreateDropDownListForFileFields(columns) CreateDropDownListForFileFields looks like this: Private Function CreateDropDownListForFileFields(ByVal columns As DataColumnCollection) As DropDownList Dim ddl As New DropDownList Dim column As DataColumn For Each column In columns ddl.Items.Add(New ListItem(column.ColumnName, column.ColumnName)) Next ddl.Items.Insert(0, New ListItem("Please select...", String.Empty)) ' Return Return ddl End Function Please see if you can help me know. Regards ma se

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          This question really should have been asked in the ASP.NET forum, reguardless of the language you used. But, in Windows Forms, any control must be added to the form's Controls collection. I'm guessing that the same is true for an ASP.NET Form.

          Me.Controls.Add(ddl)
          

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups