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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. listbox values

listbox values

Scheduled Pinned Locked Moved ASP.NET
databasequestion
7 Posts 3 Posters 1 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.
  • E Offline
    E Offline
    eyeseetee
    wrote on last edited by
    #1

    Hi I have a listbox which binds data from a database, I can see the datatextfield values but how would i see the datavaluefield values as well, i.e. show two columns in a listbox Is this possible? Is it better to use another control? thanks :)

    N D 2 Replies Last reply
    0
    • E eyeseetee

      Hi I have a listbox which binds data from a database, I can see the datatextfield values but how would i see the datavaluefield values as well, i.e. show two columns in a listbox Is this possible? Is it better to use another control? thanks :)

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      I don't think that ListBox can display data like this.

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

      E 1 Reply Last reply
      0
      • N N a v a n e e t h

        I don't think that ListBox can display data like this.

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

        E Offline
        E Offline
        eyeseetee
        wrote on last edited by
        #3

        Would a dropdownlist be better? Badically ive got some values in a listbox but I also need to get their IDs ive got them in the datavaluefield but im not sure how to view this?

        N 1 Reply Last reply
        0
        • E eyeseetee

          Would a dropdownlist be better? Badically ive got some values in a listbox but I also need to get their IDs ive got them in the datavaluefield but im not sure how to view this?

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          .netman wrote:

          dropdownlist be better?

          Nope. You won't be able to view the value. If you need just to display data, use Repeater.

          All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

          E 1 Reply Last reply
          0
          • N N a v a n e e t h

            .netman wrote:

            dropdownlist be better?

            Nope. You won't be able to view the value. If you need just to display data, use Repeater.

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

            E Offline
            E Offline
            eyeseetee
            wrote on last edited by
            #5

            ok thanks for the reply I have another question then which is related to the listbox basically i have the loop that was discussed yday but with a stored procedure in Now what I would like to do is for each row in the database it gets updated with one of the items from the listitem i.e. i have 1,2,3,4,5 in listbox then in the table it would do the following id1 = 1 id2 = 2 id3 = 3 id4 = 4 id5 = 5 However all it does at the mo is add the same number to all the ids instead of one item applied to each id Why is this? any help would be great!! thanks :) foreach (ListItem item in listbox1.Items) { SqlCommand cmd = new SqlCommand("stored_procedure", con); cmd .CommandType = CommandType.StoredProcedure; }

            N 1 Reply Last reply
            0
            • E eyeseetee

              ok thanks for the reply I have another question then which is related to the listbox basically i have the loop that was discussed yday but with a stored procedure in Now what I would like to do is for each row in the database it gets updated with one of the items from the listitem i.e. i have 1,2,3,4,5 in listbox then in the table it would do the following id1 = 1 id2 = 2 id3 = 3 id4 = 4 id5 = 5 However all it does at the mo is add the same number to all the ids instead of one item applied to each id Why is this? any help would be great!! thanks :) foreach (ListItem item in listbox1.Items) { SqlCommand cmd = new SqlCommand("stored_procedure", con); cmd .CommandType = CommandType.StoredProcedure; }

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              .netman wrote:

              However all it does at the mo is add the same number to all the ids instead of one item applied to each id

              This doesn't make any sense to me. Can you explain more ?

              All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

              1 Reply Last reply
              0
              • E eyeseetee

                Hi I have a listbox which binds data from a database, I can see the datatextfield values but how would i see the datavaluefield values as well, i.e. show two columns in a listbox Is this possible? Is it better to use another control? thanks :)

                D Offline
                D Offline
                Darsh_3
                wrote on last edited by
                #7

                u can take another listbox and bind it with previous listbox's datavaluefield. but u cant display both DataTextField & DataValueField in same ListBox

                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