ASP.NET Code
  Home arrow ASP.NET Code arrow Page 6 - How to Use the ListBox Control in ASP.NET ...
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM Developerworks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET CODE

How to Use the ListBox Control in ASP.NET 2.0
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 57
    2007-02-27

    Table of Contents:
  • How to Use the ListBox Control in ASP.NET 2.0
  • Usage of the ListBox Control in web pages
  • ListBox Examples
  • Dynamic binding to data at run time
  • Databound ListBox Example
  • Steps in converting a Unbound ListBox to a Bound ListBox

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    How to Use the ListBox Control in ASP.NET 2.0 - Steps in converting a Unbound ListBox to a Bound ListBox
    (Page 6 of 6 )

    The starting point is to drop a ListBox control on the design pane. Then click the smart tag arrow attached to the ListBox at top right to open the tasks window as shown.

    Now click the Choose Data Source... hyperlink to open the next page of the wizard.

    In this wizard use the drop-down to choose AccessDataSource1. This may open up other drop-downs. Since you are not sure of the item and the dropdown does not show any items, just click OK.

    This modifies the task list to add a new item, Configure Data Source... as shown.

    Click on Configure Data Source settings, which opens up the next screen. This screen comes up with the datasource you have already configured as shown in the next picture.

    Click on the Next button  to reveal the next screen, Configure the Select Statement. Here you can do a lot of filtering and sorting of data using all the clauses of the SQL SELECT statement. For this example only the "City" column is chosen.

    A click on the next button takes you to the following screen, Test Query, where you can test the query as shown using the Test Query button.

    When you click the Finish button you get bound to data as shown in the next picture. You may also enable AutoPostBack.

    Summary

    This tutorial described the various ways a ListBox server control in ASPNET 2.0 gets populated with either hard coded data or data from a backend database. An MS Access 2003 database was used. The ADO.NET 2.0 Data Source Controls makes the coding much easier. The GUI provides all the necessary items for fashioning appropriate queries.

    The ListBox event can be put to good use in drilling down on the data. Much of the drudgery encountered in ADO.NET 1.0 is removed for good. When configuring tasks it is advisable to switch to the source code and verify that the elements are properly configured. If you still want to use the tortuous route, you can take the route suggested in one of the examples.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Declarative binding makes it very easy to work with databases even for those who are...
       · I am using the FormView control to create a form with a number of different type of...
       · Does the stored procedure work in the management studio correctly without...
     

    ASP.NET CODE ARTICLES

    - How to Use the ListBox Control in ASP.NET 2.0
    - How to Load XML Documents in ASP.NET 2.0
    - DataGrid Code
    - ASP.NET Guestbook
    - User Controls and Client Side Scripting
    - ASP.NET Programming with Microsoft's AS...
    - ASP.NET Basics (part 3): Hard Choices
    - ASP.NET Basics (part 2): Not My Type
    - ASP.NET Basics (part 1): Nothing But .Net
    - Directory Tree Browser
    - How to get the confirmation of Yes/No from a...
    - Complete example using custom errors and wri...
    - Paging Certain # records per page .NET style
    - General Methods of formatting and Subtractin...
    - .NET LinkButton web control

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway