SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 201 | Next

Joydip Kanjilal

"ASP.NET Data Presentation Controls Essentials"


The next section discusses how you can use LINQ to bind data to ASP.NET data
controls. We will learn how we can use LINQ to bind data to GridView and the
newly introduced ListView control of Orcas.
Data Binding Using LINQ
In this section we will explore how we can use LINQ to bind data to the new data
controls introduced in Orcas, ListView and use the DataPager control for paging
through the records of the ListView control. The DataPager control is used for
providing paging features to the ListView control as the latter does not support this
feature by default. I will first show you how you can use LINQ to bind data to the
GridView control.
Drag and drop a GridView control onto your web form from the toolbox. Now, we
will create an Employee Collection class and name it as Employees. This class will
hold a collection of Employee instances.
Chapter 8
[ 227 ]
We will add the following method to our existing DataManager class:
public Employees GetAllEmployees()
{
SqlConnection conn = null;
Employees employeeList = null;
try
{
conn = new SqlConnection(connectionString);
conn.Open();
string sql = "select EmployeeID as EmpCode, EmployeeName
as EmpName, Salary as Salary, e.DepartmentID as
DeptCode, d.DepartmentName as DeptName from employee e,
Department d where e.


Pages:
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6