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. Drop Down Lists on web pages problem

Drop Down Lists on web pages problem

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netquestion
4 Posts 2 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.
  • A Offline
    A Offline
    Anoop Brijmohun
    wrote on last edited by
    #1

    Hi all, i have an intermediate knowledge on asp.net and am using Vs2005 to write the programme. i have two drop down lists on my web page and whenever i try to set the selected text, it always changes to the second one. here is a short code snippet. ************************************************************************ dim dt as new datatable dt = GetData() me.dropdownlist1.Text = CTYPE(dt.rows(0).item("Consultant1"),string).trim me.dropdownlist1.Text --> "Harry" me.dropdownlist2.Text = CTYPE(dt.rows(0).item("Consultant2"),string).trim me.dropdownlist1.Text --> "George" me.dropdownlist2.Text --> "George" ************************************************************************* when stepping through the code above the first drop down is initially correct but changes after the code passes over drop down 2.What am i doing wrong? Could you help with this, please! :sigh: Anoop Brijmohun

    B 1 Reply Last reply
    0
    • A Anoop Brijmohun

      Hi all, i have an intermediate knowledge on asp.net and am using Vs2005 to write the programme. i have two drop down lists on my web page and whenever i try to set the selected text, it always changes to the second one. here is a short code snippet. ************************************************************************ dim dt as new datatable dt = GetData() me.dropdownlist1.Text = CTYPE(dt.rows(0).item("Consultant1"),string).trim me.dropdownlist1.Text --> "Harry" me.dropdownlist2.Text = CTYPE(dt.rows(0).item("Consultant2"),string).trim me.dropdownlist1.Text --> "George" me.dropdownlist2.Text --> "George" ************************************************************************* when stepping through the code above the first drop down is initially correct but changes after the code passes over drop down 2.What am i doing wrong? Could you help with this, please! :sigh: Anoop Brijmohun

      B Offline
      B Offline
      bokuceres
      wrote on last edited by
      #2

      i'm not fully understand what your problem is. do you want to assign your each ddl's text or item? if item, you have to bind your ddl first with data, set selectedvalue and selectedtext then bind it. ddl.datasource = bla2 ddl.selectedvalue = bla2 ddl.selectedtext = bla2 ddl.databind() then select ddl.selectedvalue with your specific item. be careful if you want to assign with something that "by reference". sometimes if you don't assign it correctly, the result will goes like your problem like now. hope it helps

      A 1 Reply Last reply
      0
      • B bokuceres

        i'm not fully understand what your problem is. do you want to assign your each ddl's text or item? if item, you have to bind your ddl first with data, set selectedvalue and selectedtext then bind it. ddl.datasource = bla2 ddl.selectedvalue = bla2 ddl.selectedtext = bla2 ddl.databind() then select ddl.selectedvalue with your specific item. be careful if you want to assign with something that "by reference". sometimes if you don't assign it correctly, the result will goes like your problem like now. hope it helps

        A Offline
        A Offline
        Anoop Brijmohun
        wrote on last edited by
        #3

        Hi thanks for you help, Sorry should have mentioned this initially. My ddl's has items already in its collection, namely Harry, George. which are static i am reading and storing data into the datatable dt, which has 2 columns - Consultant1 and Consultant2. the problem i am experiencing is that when i assign ddl1 its value(Consultant1) and go to ddl2 and assign its value(Consultant2), ddl1 some how also gets assigned ddl2 value. ddl1 loses it value of harry and picks up George....... i have noe clue why... hope this helps....

        B 1 Reply Last reply
        0
        • A Anoop Brijmohun

          Hi thanks for you help, Sorry should have mentioned this initially. My ddl's has items already in its collection, namely Harry, George. which are static i am reading and storing data into the datatable dt, which has 2 columns - Consultant1 and Consultant2. the problem i am experiencing is that when i assign ddl1 its value(Consultant1) and go to ddl2 and assign its value(Consultant2), ddl1 some how also gets assigned ddl2 value. ddl1 loses it value of harry and picks up George....... i have noe clue why... hope this helps....

          B Offline
          B Offline
          bokuceres
          wrote on last edited by
          #4

          hello anoop, i'm sorry due to late to reply, because yesterday was chineses new year holiday. with how you assign the value of ddl? is it with ddl.selectedvalue ? if it doesnt work until you want to punch your monitor, why dont you fill you ddl's item dynamiclly? ddl.item.clear() ddl.item.add(new listitem("text","value")); hope it helps.. im sorry if im too late

          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