views:

80

answers:

2

How can I bind data from a database to a ListBox control in ASP.NET?

A: 

Basically, you:

  • make a connection to the database and select the data (there are a whole bunch of variables that will dictate the best way to do this)

  • ensure your data is in an IEnumerable container, such as List< object>

  • assign the IEnumerable list to the Items/ItemSource property of the control

  • call DataBind() on the control

Of course this won't work for every control, a textbox will have to be done differently. This probably didn't help you much at all, when you have more exact questions then people can give you more exact answers. If you ask vague questions with a lot of different ways of achieving the desired outcome then nobody can give you exact step by step instructions.

slugster
A: 

See Web Forms Data on the http://asp.net site.

John Saunders