i

ASP.Net A Complete Guide

Data Binding

ASP.NET provides data-bind control to bind data to the server control. It helps to perform operations such as Add, Edit, and Delete.

Below are the different ways of data-binding:

  • Simple Data Binding

  • Complex Data Binding

Simple Data Binding:

Webform control inherits DtataBind property from its parent. The inherit abilities gives the capability to bind data at least one of the property of the control.

Complex Data Binding:

Binding the data from the data sources to one of the below listed control called the complex data binding.

DataGrid, ListBox, ComboBox.

Data binding essentials:

Syntax:

<%# %>

The above syntax is used for data binding.

 

Simple syntax Example:

<%# EmpId %>

Collection (syntax for an order):


 

 

Page.DataBind() versus Control.DataBind():

When we decided to use any of the data sources to load the data, then our next part is to bind the data to those controls. Page.DataBind() and Control.DataBind() both works a similar way. Just the difference is that to bound data to control; we need Page.DataBind(). While rendering the data to the control, we use Control.DataBind():

Below are the different data-bind controls available in ASP.NET:

  • GridView Control

  • DetailsView

  • FormView

  • DropDownList

  • ListBox

  • RadioButtonList

  • CheckBoxList

  • Bullet list

  • Repeater Control

  • DataGrid Control

  • DataList Control