?
Solved

Populate combobox with dataset column names

Posted on 2006-10-25
2
Medium Priority
?
415 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 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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 …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

801 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