Avatar of macros14
macros14
 asked on

DDL Databinding Multiple Columns?

I have a dataset that has three columns in it, "id", "firstname", "lastname".  How can I bind all three columns to a dropdownlist.  I know in like vb6 it would pretty much do it automatically for you and put a line in between each column of the ddl.  Any suggestions?
ASP.NET

Avatar of undefined
Last Comment
djhex

8/22/2022 - Mon
praneetha

foreach(DataRow dr1 in dt.Rows)
                  {
      this.DropDownList1.Items.Add(dr1["id"].ToString() + " | "+dr1["firstname"].ToString() + " | " + dr1["lastname"].ToString());


                  }
djhex

macros14

ASKER
The problem is that I want each column to be aligned such as

1          Ryan           James
10        Jack            Lastnam
100      Susan         Tester
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
praneetha

i don't think you can do that in a straight forward manner...i am sure uhave to write some complicated string manipulation stuff to be bale to do that...
msato

Do you really have to use DropdownList? How many people are you going to have on the dropdownlist? If you only have 3 people, then it makes sense to use dropdownlist but if you are going to have, say, 100 people, then you may be better off using datagrid as lookup?
ASKER CERTIFIED SOLUTION
djhex

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.