ListBox query

  • Thread starter Thread starter Chubbly Geezer
  • Start date Start date
C

Chubbly Geezer

Its a really simple and common thing, but I just dont know how to make it
work!

I'm creating a web form in VS 2003 using C#, and I need to create a
dropdownlist (ddl) that is bound to records in a database. I've created the
ddl and have also used the drag and drop wizards to create an
oleDbConnection to an Access database. also a oleDbDataAdapter, and from
this have generated a dataset (also visible on the designer form). I've
tested the dataset and the preview displays all my data correctly.

In the properties of the ddl I then set the 'DataSourse', DataValueField'
and DataTextField to link the ddl with the newly generated datasaet. In the
designer view, the ddl now has 'DataBound' written within it. It seems that
this is still not sufficient to actually get the ddl to populate with data.

Any help would be appreciated.
 
Hi Chubbly,

Based on your descript, I assume that the properties of the DropDownList
has been set correctly. However, the data in the DataSet has not been
populated. You have to call the OleDbDataAdapter.Fill(DataSet) in the
Form_Load event handler to generate data. And then call DataBind on the
form to rebind controls to show the data. Here is an example:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
this.oledbDataAdapter1.Fill(this.dataSet11);
this.DataBind();
}

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Thanks Kevin. I had simply overlooked that. Struggling with moving from VB
to C# at the moment.
 
You're welcome.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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