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. Web Development
  3. ASP.NET
  4. Naming randomly a DropDownList

Naming randomly a DropDownList

Scheduled Pinned Locked Moved ASP.NET
helpquestionlounge
3 Posts 2 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
    kontax
    wrote on last edited by
    #1

    Hi, I need help for a stupid question.. I want to cicle this: DropDownList s = new DropDownList(); And so i can't use the same name for more than one DDL.. I thought to use this: Random i= new Random(); string s = i.ToString(); DropDownList s = new DropDownList(); but obviously it all ends in an error cause s was assigned before as string... Suggestions?? :sigh:

    L 1 Reply Last reply
    0
    • K kontax

      Hi, I need help for a stupid question.. I want to cicle this: DropDownList s = new DropDownList(); And so i can't use the same name for more than one DDL.. I thought to use this: Random i= new Random(); string s = i.ToString(); DropDownList s = new DropDownList(); but obviously it all ends in an error cause s was assigned before as string... Suggestions?? :sigh:

      L Offline
      L Offline
      Laddie
      wrote on last edited by
      #2

      What you ae thinking is to dinamically create s ? That is a wrong way if you want to create dynamic dropdownlist. It is not the s(That is just a pointer to the newly created object) but id that diffrentiates the dropdownlist in the runtime so give them dinamic id's Eg: Random i= new Random(); DropDownList s = new DropDownList(); s.Id = i.ToString(); How about that.

      Thanks Laddie Kindly rate if the answer was helpful

      modified on Monday, March 31, 2008 6:09 AM

      K 1 Reply Last reply
      0
      • L Laddie

        What you ae thinking is to dinamically create s ? That is a wrong way if you want to create dynamic dropdownlist. It is not the s(That is just a pointer to the newly created object) but id that diffrentiates the dropdownlist in the runtime so give them dinamic id's Eg: Random i= new Random(); DropDownList s = new DropDownList(); s.Id = i.ToString(); How about that.

        Thanks Laddie Kindly rate if the answer was helpful

        modified on Monday, March 31, 2008 6:09 AM

        K Offline
        K Offline
        kontax
        wrote on last edited by
        #3

        Yessss Thanks, that's perfect!

        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