ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing

ExpertRating Home
ExpertRating Benefits
Recommend ExpertRating
Suggest More Tests
Privacy Policy
FAQ
Login
 
ASP Dot Net Tutorial - Index
ASP Dot Net Tutorial - Microsofts ASP.NET
ASP Dot Net Tutorial - Begining Web Forms
ASP Dot Net Tutorial - User Controls
ASP Dot Net Tutorial - ADO .NET
ASP Dot Net Tutorial - DataBinding to WebControls
ASP Dot Net Tutorial - DataList Controls
ASP Dot Net Tutorial - DataGrid Control
ASP Dot Net Tutorial - Advance Practical Examples on DataGrid
ASP Dot Net Tutorial - Working with DataSets
ASP Dot Net Tutorial - Working with XML
ASP Dot Net Tutorial - Forms Based Authentication
ASP Dot Net Tutorial - Windows Based Authentication
     

 
Online Personal Trainer Certification
Personal Trainer Certification (Spanish)
Six Sigma Certification
Find a Personal Trainer
Project Management Certification
Six Sigma Certification
Six Sigma Black Belt Certification
Master Black Belt Certification
Six Sigma Green Belt Certification
Life Coach Certification
Lean Management Certification
Lean Six Sigma Certification
First Aid Certification
CPR Certification
Yoga Certification
Aerobics Certification
Pilates Certification
Business Analyst Certification
SEO Certification
Online Business Writing Course & Certification
Makeup Artist Certification
Baby Sitting Course & Certification
Time Management Certification
Health Club Management Certification
Medical Coding Certification
Medical Billing Certification
Business Analysis Course
Master Trainer Certification
Total Quality Management Certification
Kaizen Certification
Creative Writing Certification
Event Management Certification
Test Search by Job Title
Administrative Assistant Certification
Virtual Assistant Certification
  All Online Courses
   

   
   
   
   
   
   

   
  Home > Courses, Tutorials & eBooks > ASP.NET Tutorial > DataBinding to WebControls
 

ASP.NET Tutorial - DataBinding to WebControls

                                                                                                                 Page 1 of 2
 

Data binding gives extensive control over data. It refers to the process of assigning a value to a property of a runtime. For example, you can use data binding to bind the properties of a control to a data source such as the contents of a SQL Server database table. Any type of data can be bounded to any control or property of control on an ASP.NET page. Therefore this provides a check over the data movement from the data-store to the page and back again. The data can be displayed to the user, to use it for setting the style properties on a control, and allow the user to modify the data directly and update the data store.

A DataBinding class contains information about a single data-binding expression in an ASP.NET server control, which allows rapid-application development (RAD) designers, such as Visual Studio .NET, to create data-binding expressions at the time of design. This class cannot be inherited.

The following example binds the value of a function to the Text property of a Label control.

Look at the Text property of the label control: -

Text='<%# GetTime () %>'

 Special tags <%# and %> are being used here to delimit the data binding expression. Here, the value of the DataBinding expression is the value of the GetTime () function. In the subroutine Page_Load the DataBind () method is called on the Label control named lblMessage. When the DataBind ()method is called, the value of the GetTime () function is assigned to the Text property of the Label Control.

 

How to Bind a Server Control to a Data Source

This section deals with the use of DataBinding with Repeater, an important ASP.NET server control. The Repeater control does not display anything unless it is bound to a data source. Typically Repeater control is used with database applications.

Let us suppose that you have Employees table in your database and you want to display all the rows from this database table within an ASP.NET page. The following example demonstrates it: -

The output of this example is shown below:

In the above example all the rows are displayed through a SqlDataReader. Next, the SqlDataReader is assigned to the DataSource property of the Repeater control. Finally, the DataBind() method is called and the items from the SqlDataReader are bound to the Repeater control.

       

 

 

 
     
Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
 
© ExpertRating 2015. All Rights Reserved.