Data Binding in ASP.NET

Data Binding in ASP.NET

Data Binding is a process of getting data from any data-source and binding data to  data-access-controls.

Data Access Controls

  • Tabular Data Display [Rows & Columns]

<asp:Repeater, DataList, DataGrid, GridView, ListView

  • One Column of Data Display

<asp:DropDownList, RadioButtonList, CheckBoxList, ListBox

  • One Row[Record] of Data Display

<asp:DetailsView, FormView

Data Source(s)

There are 3 types of data sources

1. Run-time generated data source(s)

System Namespace – Array Class
System.Collections Namespace – ArrayList, Hashtable, Stack, Queue etc.
System.Collections.Generic Namespace – List<T>  generic  class

Tabular [2D] data storing

System.Data Namespace – DataTable, DataSet, DataView  classes

2. Flat Files [No Integrated Security]

a) XML Data Files[.xml]
b) Data Text Files [.txt] [CSV Files]

Comma Separated Values school.txt

1, Albert Singh, V, 250.00, 2nd Street – Munirka

11, Robert Singh, VI, 1250.00, 22nd Street – Munirka


c) Ms Office Documents

Ms Office 2003, 2007

– InfoPath Technology, with SharePoint Web Server

3. Database(s) – Integrated Security

i) DBMS [Ole Db Tech]
ii) RDBMS [ODBC Tech]
iii) OO – DBMS [Integration with OOPS Language] Oracle 8i onwards : Java – PL/SQL integration SQL Server 2005: C# – TSQL intergration
iv) XML – DBMS .XSD format data,  SQL Server 2000 onwards,  Oracle 8i onwards

Hybrid DBMS

– All the above mentioned capabilities

SQL Server 2000 onwards

Oracle 8i onwards.

Internet-Ready DBMS

• Working capability of Max. numbers of online  con-current  users.

• XML Data Conversion Capability

– Internet is a Multi-OS environment

– XML data requirement for mobile / micro devices.

Array

int []   arInt  = new int[5]; arInt[3] = 55;
string []  arStr = new string[] {“One”, “Two”, “Three”, “Four”, “Five”};
arStr[2] = “Thirty Three”;
arInt.Length // int 5 arStr.Length // 5
arInt.Rank // int 1 arStr.Rank 1

2D

float[ , ]    arFloat  = new float[2, 5]; arFloat[1, 3] = 7.55F;
arFloat.Length // 10 arFloat.Rank // 2

Jagged Array

string [ ] [ ]   arsj   = new string [3] [ ];
string [ ] [ , ]   ars2j   = new string [3] [ , ];
string [ , ] [ ]   ars3j   = new string [2, 3] [ ];
string [ , ] [ , ]   ars4j   = new string [3, 5] [ , ];

Data Binding Statements

Container object

1D —- <%#    Container.DataItem  %>

2D —- 2D means multiple columns.

Column-wise parsing of data is neccessary.
<%#   DataBinder.Eval(Container.DataItem, “Col1”) %>

<%#   DataBinder.Eval(Container.DataItem, “Col2”) %>

GridView has  AutoGenerateColumns=”true”.  So data binding is optional.
Data Binding statements are MUST neccessary in Repeater & DataList for data-display.
<asp:DataList  id=”DataList1″ runat=server > <ItemTemplate> <%# Container.DataItem %> </ItemTemplate> </asp:DataList>

Other Template Tags for Formatted Data Display
<HeaderTemplate>
<ItemTemplate> <AlternatingItemTemplate>
<SeparatorTemplate>
<FooterTemplate>

Source: Md. Sadiq sir. thanks sir for wonderful contribution on Data Binding in ASP.NET

R K Gupta

Hi, This is R K Gupta, an IT professional and Entrepreneur. I have written many articles yet for my websites gsesoftsolutions.com, Hope you like it. Kindly subscribe our feed for any updates. Add me in Facebook and Google+

More Posts - Website

Follow Me:
TwitterFacebookPinterestYouTube

Hi, This is R K Gupta, an IT professional and Entrepreneur. I have written many articles yet for my websites gsesoftsolutions.com, Hope you like it. Kindly subscribe our feed for any updates. Add me in Facebook and Google+

Posted in Database Management, Microsoft .Net Help, Software Development