471,350 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

ListBox query

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.
Dec 1 '05 #1
3 1192
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."

Dec 2 '05 #2
Thanks Kevin. I had simply overlooked that. Struggling with moving from VB
to C# at the moment.
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:7s*************@TK2MSFTNGXA02.phx.gbl...
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."

Dec 2 '05 #3
You're welcome.

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

Dec 2 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Colleyville Alan | last post: by
2 posts views Thread by dachrist28 | last post: by
2 posts views Thread by Mirnes | last post: by
3 posts views Thread by deejayquai | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.