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. Same selectedvalue in dropdownlist??

Same selectedvalue in dropdownlist??

Scheduled Pinned Locked Moved ASP.NET
csharpdatabaseasp-netsql-serverwpf
8 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
    Karan_TN
    wrote on last edited by
    #1

    i m currently using ASP.NET with C# (.net 2005, 2.0 framework) i m taking the TEXT,VALUE from database (SQL server) and binding to an dropdownlist box. some values are same and the text differ. for example the text and value i m binding to an dropdownlist is mentioned below. First - 1 Second - 2 Third - 3 front - 1 Rear - 1 when i bind the above values and process, i cant pick up the values properly. once the "front" is selected, and i attempt to change for "Rear" or "First", its not reflecting... Why this problem?. thanks in advance...

    E K 2 Replies Last reply
    0
    • K Karan_TN

      i m currently using ASP.NET with C# (.net 2005, 2.0 framework) i m taking the TEXT,VALUE from database (SQL server) and binding to an dropdownlist box. some values are same and the text differ. for example the text and value i m binding to an dropdownlist is mentioned below. First - 1 Second - 2 Third - 3 front - 1 Rear - 1 when i bind the above values and process, i cant pick up the values properly. once the "front" is selected, and i attempt to change for "Rear" or "First", its not reflecting... Why this problem?. thanks in advance...

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

      What do you mean by:

      Karan_TN wrote:

      once the "front" is selected, and i attempt to change for "Rear" or "First"

      How are you changing this?

      1 Reply Last reply
      0
      • K Karan_TN

        i m currently using ASP.NET with C# (.net 2005, 2.0 framework) i m taking the TEXT,VALUE from database (SQL server) and binding to an dropdownlist box. some values are same and the text differ. for example the text and value i m binding to an dropdownlist is mentioned below. First - 1 Second - 2 Third - 3 front - 1 Rear - 1 when i bind the above values and process, i cant pick up the values properly. once the "front" is selected, and i attempt to change for "Rear" or "First", its not reflecting... Why this problem?. thanks in advance...

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

        Thanks for replying.... public void fxn() { MyLib.conn.Open(); MyLib.sqlda = new SqlDataAdapter("select TEXT,VALUE from tbl_test where criteria=hello", conn); sqlda.Fill(MyLib.ds); cbovalue1.DataValueField = "VALUE"; cbovalue1.DataTextField = "TEXT"; cbovalue1.DataSource = MyLib.ds; cbovalue1.DataBind(); cbovalue1.Items.Insert(0, new ListItem("", "")); ds.Reset(); ds.Clear(); ds.Dispose(); sqlda.Dispose(); conn.Close(); } by using the above coding i m binding the VALUE,TEXT to cbovalue1 dropdownlist box. when i m changing the value its not reflecting (as mentioned in my previous scrap). help me...

        E T 2 Replies Last reply
        0
        • K Karan_TN

          Thanks for replying.... public void fxn() { MyLib.conn.Open(); MyLib.sqlda = new SqlDataAdapter("select TEXT,VALUE from tbl_test where criteria=hello", conn); sqlda.Fill(MyLib.ds); cbovalue1.DataValueField = "VALUE"; cbovalue1.DataTextField = "TEXT"; cbovalue1.DataSource = MyLib.ds; cbovalue1.DataBind(); cbovalue1.Items.Insert(0, new ListItem("", "")); ds.Reset(); ds.Clear(); ds.Dispose(); sqlda.Dispose(); conn.Close(); } by using the above coding i m binding the VALUE,TEXT to cbovalue1 dropdownlist box. when i m changing the value its not reflecting (as mentioned in my previous scrap). help me...

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

          Do you mean you have changed a value in the database and it is not reflecting in the dropdown list?

          K 1 Reply Last reply
          0
          • K Karan_TN

            Thanks for replying.... public void fxn() { MyLib.conn.Open(); MyLib.sqlda = new SqlDataAdapter("select TEXT,VALUE from tbl_test where criteria=hello", conn); sqlda.Fill(MyLib.ds); cbovalue1.DataValueField = "VALUE"; cbovalue1.DataTextField = "TEXT"; cbovalue1.DataSource = MyLib.ds; cbovalue1.DataBind(); cbovalue1.Items.Insert(0, new ListItem("", "")); ds.Reset(); ds.Clear(); ds.Dispose(); sqlda.Dispose(); conn.Close(); } by using the above coding i m binding the VALUE,TEXT to cbovalue1 dropdownlist box. when i m changing the value its not reflecting (as mentioned in my previous scrap). help me...

            T Offline
            T Offline
            trish_
            wrote on last edited by
            #5

            Here some fields have same values like First,front & rear have value 1. Hence if you select any text which has same value it points to first text which has value 1. solution : if possible change you sql quesry as select TEXT,concat(VALUE,TEXT)as VALUE from tbl_test where criteria=hello" now you will get the required text selected. If you need a value of selected,you need to pick only VALUE part from (VALUE,TEXT) combination

            trish http://AllJobSearch.blogspot.com

            modified on Monday, April 28, 2008 7:13 AM

            K 1 Reply Last reply
            0
            • T trish_

              Here some fields have same values like First,front & rear have value 1. Hence if you select any text which has same value it points to first text which has value 1. solution : if possible change you sql quesry as select TEXT,concat(VALUE,TEXT)as VALUE from tbl_test where criteria=hello" now you will get the required text selected. If you need a value of selected,you need to pick only VALUE part from (VALUE,TEXT) combination

              trish http://AllJobSearch.blogspot.com

              modified on Monday, April 28, 2008 7:13 AM

              K Offline
              K Offline
              Karan_TN
              wrote on last edited by
              #6

              hai trish....... there is no function CONCAT in MS SQL server

              T 1 Reply Last reply
              0
              • E eyeseetee

                Do you mean you have changed a value in the database and it is not reflecting in the dropdown list?

                K Offline
                K Offline
                Karan_TN
                wrote on last edited by
                #7

                hai .netman, not changing the value in database. when i change the text in dropdownlist, its not fetching the value of the particular "selecteditem" for example if the drop down list consist of "A,B,C,D,E" as {dropdowntext} and the values are A=1;B=1;C=4;D=1;E=2; so,....... when i select the "A" no problem. sequencly i select "B", no problem. again i select "D", its not selecting.instead "A" remains there.

                1 Reply Last reply
                0
                • K Karan_TN

                  hai trish....... there is no function CONCAT in MS SQL server

                  T Offline
                  T Offline
                  trish_
                  wrote on last edited by
                  #8

                  Yes there is no CONCAT fucntion in Sql Server .it's in ORACLE For Sql Server you can do the same thing with + sign e.g Select First_Col + Second_col from table

                  trish http://AllJobSearch.blogspot.com

                  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