ASP.NET ListBox - Populating with Data - ObjectDataSourc

  • ShipName_11
  • ShipName_22
  • ShipName_33
  • ShipName_44
  • ShipName_55
  • ShipName_66
  • ShipName_77
  • ShipName_88
  • ShipName_99
  • ShipName_1010
  • ShipName_1111
  • ShipName_1212
  • ShipName_1313
  • ShipName_1414
  • ShipName_1515
  • ShipName_1616
  • ShipName_1717
  • ShipName_1818
  • ShipName_1919
  • ShipName_2020
  • ShipName_2121
  • ShipName_2222
  • ShipName_2323
  • ShipName_2424
  • ShipName_2525
The ListBox can be populated from various types of data sources:
  • DataSourceControls - SqlDataSource, ObjectDataSource, LinqDataSource etc.;
  • LINQ - LINQ queries at runtime;
  • Collections (generic & non-generic) - IList, IEnumerable, etc.;
  • DataSet / DataTable;
  • Declarative

The ListBox presented in this sample is populated from a ObjectDataSource control. This is done by setting the DataSourceID property of the ListBox to be the ID of the ObjectDataSource control. Also, the DataValueField and DataTextField properties need to be used to specify the name of the database fields that will be used to populate the Value and Text properties of the generated ListBoxItems.

"I try out other tools from time to time but always end up seeing if I can do what I need with the obout suite because you make the best ones!"

Daniel C. Hall

obout.com 
obout.com Home 
News 
Listbox Home   
Listbox Home 
Examples - 49
Appearance - 2 
Live Styles 
Different Styles New 
Load on Demand - 3 
Load Items on Demand 
Load Items on Demand with Paging  
Virtual Scrolling  
Multi-Columns - 4 
Grid-like Multi-Columns  
Multiple Rows and Columns  
Load multi Columns on Demand  
State Selector  
Items with Icons - 3 
Items with Icons  
Grid-like Multi-Columns with Icons  
Multiple Rows and Columns with Icons  
Templates - 3 
Item Templates  
Header Templates  
Populating with Data - 5 
Declarative  
SqlDataSource  
ObjectDataSource  
Generic Collections  
DataSet  
Item Selection - 6 
Single Item Selection  
Multi Item Selection  
Get Selected Item  
Get Selected Items  
Set Selected Item New 
Set Selected Items New 
Master/Detail - 3 
Master/Detail  
Unlimited Detail Levels  
Cascading ListBoxes  
Integration - 4 
Items with ASP.NET CheckBoxes  
Items with Obout CheckBoxes  
RadioButtons inside ListBox  
ListBox inside Grid  
Settings - 3 
AutoPostback  
Height  
Width  
Server-Side API - 4 
Server-Side Events  
Enable / Disable  
Get Values from Multiple Columns New 
Tooltips New 
Client-Side API - 8 
Client-Side Events  
Add / Remove Items  
Add Multi-Column Items New 
Enable / Disable  
Get Selected Item  
Reset Selection New 
Select / Deselect All Items New 
Move Items New 
Appearance Customization - 1 
Aligning Items New 
Knowledge Base - 1 
Knowledge Base 
Documentation - 11 
Server-Side 
ListBox 
ListBoxClientSideEvents 
ComboBoxCssSettings 
ListBoxFooterTemlateContainer 
ListBoxHeaderTemlateContainer 
ListBoxItem 
ListBoxItemEventArgs 
ListBoxItemTemlateContainer 
ListBoxLoadingItemsEventArgs 
Client-Side 
Client-Side API 
ChangeLog 
Tutorials - 2 
Appearance - 1 
CSS Tutorial  
Configuration - 1 
Using the correct path