Populating Dropdownlist with dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Folks

I've been dumped in at the deepend and need to understand the answer pretty
quickly. I've got a dropdownlist and need to use Microsoft Data Access
Blocks; so implementing a Dataset, how do I populate the list with the
contents from a table called Parameters.
Also does anyone know of a very good site that will explain C# to me in the
least amount of time?

Cheers in advance.
 
Hi,

I believe that your post would have been better suited for the ASP.net
newsgroup. That group will answer specific questions that you have about
ASP. net.

I have provided a code sample for you below that demonstrates how to bind a
drop down list to a dataset using the Microsoft.Application blocks. Just
remember that there is no exception handling (except for what is in the
Application Block) so you will need to add your own. There are also a couple
of links to get you started with Asp.net and the related architecture.

Hope this Helps


----------------Links-------------
http://samples.gotdotnet.com/quickstart/
http://www.microsoft.com/resources/practices/default.mspx


----------------Code-------------
string strConn = "Data Source=(local);Initial Catalog=Northwind;User
Id=sa;Password=password;" ;
string strSelect = "SELECT TOP 10 Products.ProductName FROM Products" ;
DataSet ds = new DataSet();
string[] tablenames = {"Products"};

SqlHelper.FillDataset(strConn,CommandType.Text,strSelect,ds,tablenames);
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = ds.Tables["Products"].Columns[0].ToString();
DropDownList1.DataBind();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top