Article ID: 313481 - Last Review: March 29, 2007 - Revision: 5.5 INFO: Roadmap for Web Forms Data BindingThis article was previously published under Q313481 On This PageSUMMARY This article provides a roadmap to learn and master data
binding using ASP.NET Web Forms. To assist you with learning a Microsoft
product or technology, roadmap articles provide links to useful information,
including online documentation, Microsoft Knowledge Base articles, and white
papers. This article contains the following sections:
OverviewWith Web Forms pages, you can display information by binding controls to a source of data (as with most types of forms). However, data binding in Web Forms pages is somewhat different from data binding in other technologies, because of the nature of Web Forms pages themselves and the architecture of Web programming. With .NET Windows Forms and Web Forms, you can now bind to virtually any property of a control. This topic provides background information about data binding in Web Forms pages, how to work with data binding in your Web applications, and where you can find more information about data binding and data access in Web Forms pages. Data binding in Web Forms pages is flexible. You can bind any property of a control to data. This flexibility makes data binding in Web Forms pages different from previous types of date binding. In other types of data binding, you typically bind the display property (for example, the text property of a text box) to the data source. In Web Forms pages, your data source can be almost any type of information that is available to the page, whether the information comes from a database, from an XML document, from another control or process, or even from a calculation that you perform yourself. With Web Forms data binding you can assign this data to any property of any control. Therefore, you can use data binding to perform actions such as:
For overview information about data binding by using ASP.NET Web Forms, visit the following Microsoft Web sites: Web Forms Data Binding
(http://msdn2.microsoft.com/en-us/library/aa984095(vs.71).aspx)
Introduction to Data Binding in Web Forms Pages
(http://msdn2.microsoft.com/en-us/library/aa710844(vs.71).aspx)
Data-Binding Expressions for Web Forms Pages
(http://msdn2.microsoft.com/en-us/library/aa983586(vs.71).aspx)
For additional information, click the article number below
to view the article in the Microsoft Knowledge Base: 307860
(http://support.microsoft.com/kb/307860/EN-US/
)
ASP.NET Data Binding Overview
ArchitectureYou can bind any single-value Web server control property to a data value (for example, you can bind the Text property of a TextBox or the ImageUrl property of an Image control). This includes not only display properties, but behavior properties such as size, width, and font. You specify single-value data binding by creating a data-binding expression. In Microsoft Visual Studio, you can use design-time tools to create this expression automatically. When the control performs data binding, it resolves the expression and assigns the resulting value to the specified property. You can data bind as many properties on a control as you want to.For documentation about key Web Form data binding concepts, visit the following Microsoft Web sites: Data Binding Single-Value Web Server Controls at Design Time
(http://msdn2.microsoft.com/en-us/library/aa713238(vs.71).aspx)
Data Binding Single-Value Web Server Controls at Run Time
(http://msdn2.microsoft.com/en-us/library/aa713239(vs.71).aspx)
ControlsSome Web Forms controls display values from multiple records at one time. These controls include the Repeater, DataList, DataGrid, ListBox, CheckBoxList, and RadioButtonList Web server controls, and the HtmlSelect control. Other controls, such as Label, TextBox, CheckBox, and Hyperlink controls, display single values, which in data-binding terms means values from a single record. For more information, visit the following Microsoft Web sites:Multi-Record and Single-Value Data Binding for Web Forms Pages
(http://msdn2.microsoft.com/en-us/library/aa711431(vs.71).aspx)
Data-Binding Expressions for Web Forms Pages
(http://msdn.microsoft.com/en-us/library/aa983586(VS.71).aspx)
The "Data-Binding Expressions for Web Forms Pages" Web site
describes how Web Forms control data binding is specified through the use of a
special syntax. The Web site covers the following topics:
Control.DataBind MethodControl.DataBind Method
(http://msdn.microsoft.com/en-us/library/w5e5992d.aspx)
The Control.DataBind method binds a data source to the invoked server control and all
its child controls. Use this method to bind data from a source to a server
control. You typically use this method after you retrieve a data set through a
database query. The "Control.DataBind Method" Web page also contains an example
that demonstrates how to override the DataBind method in a custom control. DataBinder ClassDataBinder Class
(http://msdn.microsoft.com/en-us/library/system.web.ui.databinder.aspx)
This Web site provides support for rapid-application development
(RAD) designers to generate and parse Data Binding Expression Syntax. This
class cannot be inherited. DataBinder MembersDataBinder Members
(http://msdn.microsoft.com/en-us/library/system.web.ui.databinder_members.aspx)
This Web site has a list of all the DataBinder class members. DataBinder.Eval MethodDataBinder.Eval Method
(http://msdn.microsoft.com/en-us/library/4hx47hfe.aspx)
The DataBinder.Eval method uses reflection to parse and evaluate a data-binding
expression against an object at run time. This method allows rapid-application
development (RAD) designers, such as Visual Studio .NET, to easily generate and
parse data-binding syntax. You can also use this method declaratively on a Web
Forms page to simplify casting from one type to another. This Web site contains
an example that shows how to use one of the overloaded versions of Eval. Control.OnDataBinding MethodControl.OnDataBinding Method
(http://msdn.microsoft.com/en-us/library/system.web.ui.control.ondatabinding(VS.71).aspx)
The Control.OnDataBinding method raises the DataBinding event. This method notifies a
server control to perform any data binding logic that is associated with it.
This Web site contains an example that demonstrates how to override the
OnDataBinding method to add child controls to the parent control from a data
source. DataBinding ClassDataBinding Class
(http://msdn.microsoft.com/en-us/library/system.web.ui.databinding.aspx)
This Web site contains information about a single data-binding
expression in an ASP.NET server control. This single data-binding expression
allows RAD designers, such as Visual Studio .NET, to create data-binding
expressions at design time. This class cannot be inherited. DataBindingCollection ClassDataBindingCollection Class
(http://msdn.microsoft.com/en-us/library/system.web.ui.databindingcollection.aspx)
The DataBindingCollection class provides a collection of DataBinding objects for an ASP.NET
server control. This class cannot be inherited. This Web site contains an
example that demonstrates how to use the DataBindingCollection constructor. DataBindingCollection MembersDataBindingCollection Members
(http://msdn.microsoft.com/en-us/library/system.web.ui.databindingcollection_members.aspx)
The "DataBindingCollection Members" Web site has a list of all
members of the DataBindingCollection class. Control.DataBinding EventControl.DataBinding Event
(http://msdn.microsoft.com/en-us/library/system.web.ui.control.databinding.aspx)
The Control.DataBinding event occurs when the server control binds to a data source. The
event handler receives an argument of the EventArgs type that contains data
that is related to this event. This event notifies the server control to
perform any data binding logic that has been written for it. IDataBindingsAccessor InterfaceIDataBindingsAccessor Interface
(http://msdn.microsoft.com/en-us/library/system.web.ui.idatabindingsaccessor.aspx)
With the IDataBindingsAccessor interface, the collection of
data-binding expressions on a control can be accessed at design time. IDataBindingsAccessor MembersIDataBindingsAccessor Members
(http://msdn.microsoft.com/en-us/library/system.web.ui.idatabindingsaccessor_members.aspx)
This Web site has a list of all the members of the
IDataBindingsAccessor interface. QuickStart TutorialsFor QuickStart tutorials, visit the following Microsoft Web sites:ASP.NET QuickStart
(http://msdn.microsoft.com/en-us/library/aa719467(VS.71).aspx)
ASP.NET Data Binding
(http://msdn.microsoft.com/en-us/library/8yc44h4d(VS.85).aspx)
For more information about data binding server controls, visit
the following Microsoft GotDotNet Web site: Data Binding Server Controls
(http://msdn.microsoft.com/en-us/library/aa713235(VS.71).aspx)
For more information about templated data-bound controls, visit
the following Microsoft Web site: Sample Templated Data-Bound Control
(http://msdn.microsoft.com/en-us/library/aa720696(VS.71).aspx)
For more information about server controls, visit the following
Microsoft Web site: Server Control Samples
(http://msdn.microsoft.com/en-us/library/aa720607(VS.71).aspx)
How To ArticlesHow To articles in the Microsoft Knowledge Base contain step-by-step instructions about how to do specific tasks. For additional information about data binding with ASP.NET Web Forms, click the article numbers below to view the articles in the Microsoft Knowledge Base:308485
(http://support.microsoft.com/kb/308485/EN-US/
)
HOW TO: Create a Master/Detail Page with Web Form Controls
308485
(http://support.microsoft.com/kb/308485/EN-US/
)
HOW TO: Create a Master/Detail Page with Web Form Controls
306227
(http://support.microsoft.com/kb/306227/EN-US/
)
HOW TO: Use a CheckBox Web Control in a DataGrid
314334
(http://support.microsoft.com/kb/314334/EN-US/
)
HOW TO: Add Static Items to a DropDownList Control Using VB .NET
317429
(http://support.microsoft.com/kb/317429/EN-US/
)
HOW TO: Use the ItemDataBound Event in VB.Net Web Forms
317719
(http://support.microsoft.com/kb/317719/EN-US/
)
HOW TO: Export Data in DataGrid on an ASP. NET WebForm to Excel
313154
(http://support.microsoft.com/kb/313154/EN-US/
)
HOW TO: Create Summary Row for DataGrid in ASP.NET Using VB .NET
317794
(http://support.microsoft.com/kb/317794/EN-US/
)
HOW TO: Dynamically Create Controls in ASP.NET w/Visual C# .NET
WalkthroughsWalkthroughs are mini-tutorials that walk you through some typical application development scenarios using Web Forms data binding. For walkthrough documents, visit the following Microsoft Web sites:Walkthrough: Updating Data Using a Database Update Query in Web Forms
(http://msdn2.microsoft.com/en-us/library/aa728894(vs.71).aspx)
Walkthrough: Using a DataGrid Web Control to Read and Write Data
(http://msdn2.microsoft.com/en-us/library/aa728895(vs.71).aspx)
The "Using a DataGrid Web Control" walkthrough assists you with
developing a templated data-bound control. It is easy to bind a property of a
control to a single data item (or expression) by using ASP.NET data-binding
syntax. This section addresses the more complex scenario of developing a
control that has templated properties bound to a data source that is a
collection type (System.Collections.ICollection or
System.Collections.IEnumerable). Templates enable a page developer to customize
the presentation of data that is bound to the control. The Repeater and
DataList controls are examples of templated data-bound controls. For additional information about how to develop templated data-bound controls, visit the following Microsoft Web site: Developing a Templated Data-Bound Control
(http://msdn.microsoft.com/en-us/library/aa719971(VS.71).aspx)
TroubleshootingThe Microsoft newsgroups and the Microsoft Knowledge are both valuable resources for troubleshooting.In the Microsoft newsgroups, your peers can answer problems and questions. To view the Microsoft newsgroups, visit the following Microsoft Web site: MSDN Newsgroups
(http://msdn.microsoft.com/newsgroups/)
To search for articles about specific issues in the Microsoft
Knowledge Base (KB), visit the following Microsoft Web site: Microsoft Knowledge Base
(http://support.microsoft.com/search/?adv=1)
For additional information to help you with troubleshooting,
visit the following Microsoft Web sites: MSDN Library
(http://msdn.microsoft.com/en-us/library/default.aspx)
MSDN Online .NET Developer Center
(http://msdn.microsoft.com/net)
REFERENCES For information about
how to work with ASP.NET, view the ASP.NET QuickStart tutorial at the following
Microsoft GotDotNet Web site: ASP.NET QuickStart Tutorial
(http://quickstarts.asp.net/QuickStartv20/aspnet/Default.aspx)
For additional information, click the
article number below to view the article in the Microsoft Knowledge Base: 313485
(http://support.microsoft.com/kb/313485/EN-US/
)
INFO: Roadmap for ADO.NET DataSet, DataView, and DataViewManager
| Article Translations
|
Back to the top
