Binding dataset to a ListBox.

J

Jason Huang

Hi,

In ASP.Net C# windows form, how do I bind a DataSet to a ListBox so the
ListBox will display data?
Thanks for help.

Jason
 
M

Mark Rae

In ASP.Net C# windows form

ASP.NET uses WebForms, not WinForms.

Are you talking about binding a datasource to an <asp:ListBox /> WebControl
on an ASPX page?

Please clarify...
 
W

W.G. Ryan MVP

listBoxName.DataSource = DataSet.Tables[TableIndex];
listBoxName.DataTextField = "FieldName";
listBoxName.DataValueField = "FieldName";
listBoxName.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

Top