Solved

Populate combobox with dataset column names

Posted on 2006-10-25
2
408 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
2 Comments
 
LVL 29

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
network + 7 73
ConsoleSql 1 21
bulid json format 3 21
How to LOAD up a .NET Framework website with data? 2 16
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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now