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. C#
  4. How to add items in listbox from database

How to add items in listbox from database

Scheduled Pinned Locked Moved C#
databasetutorial
3 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.
  • K Offline
    K Offline
    kaushik_dass
    wrote on last edited by
    #1

    i tried to add the items in listbox from database but it adds only one record from database

    M P 2 Replies Last reply
    0
    • K kaushik_dass

      i tried to add the items in listbox from database but it adds only one record from database

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      how did you try to do it? post some example code

      Life goes very fast. Tomorrow, today is already yesterday.

      1 Reply Last reply
      0
      • K kaushik_dass

        i tried to add the items in listbox from database but it adds only one record from database

        P Offline
        P Offline
        PauloCastilho
        wrote on last edited by
        #3

        Try to use this two properties: DataValueField and DataTextField. e.g. //SOURCE_FROM_DB -> The method or object or ... whatever ... that has the items. myListBox.DataSouce = SOURCE_FROM_DB; //VALUE_COLUMN_NAME -> The column name of the DataSource that represents the VALUE of the item. myListBox.DataValueField = "VALUE_COLUMN_NAME"; //TEXT_COLUMN_NAME -> The column name of the DataSource that represents the TEXT of the item. myListBox.DataTextField = "TEXT_COLUMN_NAME"; myListBox.DataBind();

        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