Solved

Populate combobox with dataset column names

Posted on 2006-10-25
2
412 Views
Last Modified: 2010-04-16
Hi guys,

I am jumping from vb.net to C# and I am not very familiar with C# but need to force myself to use it.

How can I populate a combobox with a datasets column names?

Usually in vb.net I would do a

for each column in sqldatasource
  dropdownlist.items.add(column.name)
next

Thanks,
Pad
0
Comment
Question by:Paddlefoot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 30

Accepted Solution

by:
anarki_jimbel earned 50 total points
ID: 17808292
If you use e.g. DataAdapter with a DataTable, and want to filll a dropdown list with DataTable's column names you do something like:

            //e.g.: DataTable tbl = new DataTable();

            foreach (DataColumn col in tbl.Columns)
            {
                dropdownlist.Items.Add(col.ColumnName);
            }
0
 

Author Comment

by:Paddlefoot
ID: 17808308
Too easy! Thanks anarki.

Pad
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question