Solved

Populate combobox with dataset column names

Posted on 2006-10-25
2
413 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

Technology Partners: 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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 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