With ASP.NET 2.0, you have a much simpler syntax as the DataBinder instance is
now the default context for all data binding expressions that are used for displaying
non-hierarchical data in your presentation layer. You can now use any of the
following overloaded versions of the Eval() method for binding data.
<%# Eval("expression") %>
<%# Eval("expression"[, "format"]) %>
The Employee and the Data Manager Classes
Before we dig into a discussion on the data source controls in ASP.NET that follows
this section, I would present here two classes that we would frequently be using here
and after in the book; I would use these classes throughout this book. In order to
reduce code duplication or redundancy, I am providing here the source code for both
these classes; we would refer them elsewhere.
The Employee class in this example is the Business Entity class. It contains a set of
public properties that expose the data members of the class. The source code for this
class is as follows:
public class Employee
{
private string empCode = String.Empty;
private string empName = String.Empty;
private double basic = 0.0;
private string deptCode = String.Empty;
private DateTime joiningDate;
Chapter 1
[ 9 ]
public string EmpCode
{
get
{
return empCode;
}
set
{
empCode = value;
}
}
public string EmpName
{
get
{
return empName;
}
set
{
empName = value;
}
}
public double Basic
{
get
{
return basic;
}
set
{
basic = value;
}
}
public string DeptCode
{
get
{
return deptCode;
}
set
{
deptCode = value;
}
Introduction to Data Binding in ASP.
Pages:
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30