DropDownList Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nikky
    New Member
    • Nov 2006
    • 25

    #1

    DropDownList Problem

    I m using C#.net
    i m retriving values from database.
    DropDownList1.D ataSource = objdd.result;
    DropDownList1.D ataTextField = "schm_name" ;
    DropDownList1.D ataValueField = "schm_code" ;
    DropDownList1.D ataBind();

    Now i want to concatinate more string at datatextfied at run time.

    like DropDownList1.D ataTextField = "schm_name"+"go rup"+"my name";
    how can i perform this ???
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Did this work? If not suggest using variable.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by Nikky
      I m using C#.net
      i m retriving values from database.
      DropDownList1.D ataSource = objdd.result;
      DropDownList1.D ataTextField = "schm_name" ;
      DropDownList1.D ataValueField = "schm_code" ;
      DropDownList1.D ataBind();

      Now i want to concatinate more string at datatextfied at run time.

      like DropDownList1.D ataTextField = "schm_name"+"go rup"+"my name";
      how can i perform this ???
      Have you tried to us the code you have posted here?
      It seems like it should work.
      What problem are you having?

      -Frinny

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        In the past I have had to modify the my SELECT statement to include a concatinated entry such as:
        Code:
        SELECT 
         * 
         , ( [Last Name] + ', ' + [First Name]) AS [DISPLAYVALUE] 
         FROM 
         people 
        ;

        Comment

        • Nikky
          New Member
          • Nov 2006
          • 25

          #5
          Originally posted by Frinavale
          Have you tried to us the code you have posted here?
          It seems like it should work.
          What problem are you having?

          -Frinny

          No its not working.It will work only with the schm_name bcoz it is column name.group and my name are the another string which i want to show at run time after concate with the schm_name.

          there is a error in "DataBind() " bcoze "schm_name+grou p+my name" are dynamic dropdownlist is unable to bind it

          Comment

          • vinaykumar Maladkar
            New Member
            • Feb 2007
            • 17

            #6
            The DataTextField of the control requires a column name of the data source.
            As u r concating different strings this column name doesnot exist in the datasource, therefore it will not work.

            Comment

            • Nikky
              New Member
              • Nov 2006
              • 25

              #7
              Originally posted by Plater
              In the past I have had to modify the my SELECT statement to include a concatinated entry such as:
              Code:
              SELECT 
               * 
               , ( [Last Name] + ', ' + [First Name]) AS [DISPLAYVALUE] 
               FROM 
               people 
              ;
              ThnkX plater this code is working but now there is another problem i m using it in a loop each n every time concatinated string is changed .Now Dropdownlist showing only last concatinated value.

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                Originally posted by Nikky
                I m using C#.net
                i m retriving values from database.
                DropDownList1.D ataSource = objdd.result;
                DropDownList1.D ataTextField = "schm_name" ;
                DropDownList1.D ataValueField = "schm_code" ;
                DropDownList1.D ataBind();

                Now i want to concatinate more string at datatextfied at run time.

                like DropDownList1.D ataTextField = "schm_name"+"go rup"+"my name";
                how can i perform this ???

                Have you tried looping through objdd.result and adding new items manually instead of doing a DataBind?


                eg (Note that this code probably wont work....)
                Code:
                For(i=0; i<objdd.result.length; i++)
                {    DropDownList1.Items.Add(New ListItem("value", "index"));}

                Comment

                • Plater
                  Recognized Expert Expert
                  • Apr 2007
                  • 7872

                  #9
                  so each of your SQL statements only returns one item? If that is true, it seems like that would hammer on the database, you should consider re-working your SQL statements

                  Comment

                  Working...