Close();
DataSet ds = new DataSet();
FillEmployeesDataSet(ds);
repeaterDtEmp.DataSource = ds;
repeaterDtEmp.DataMember = "Employees";
repeaterDtEmp.DataBind();
}
}
private SqlDataReader GetCustomerDataReader()
{
SqlConnection conn =
new SqlConnection(WebConfigurationManager.ConnectionStrings["NorthWindDB"]
.ConnectionString);
conn.Open();
318 CHAPTER 7 ?– SE RVER CONTROL DATA B INDING
SqlCommand cmd =
new SqlCommand("SELECT CustomerID, ContactName, ContactTitle,
CompanyName FROM Customers WHERE CustomerID LIKE '[AB]%'",
conn);
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return dr;
}
private void FillEmployeesDataSet(DataSet ds)
{
SqlConnection conn =
new SqlConnection(WebConfigurationManager.ConnectionStrings["NorthWindDB"]
.ConnectionString);
conn.Open();
SqlDataAdapter da =
new SqlDataAdapter("SELECT EmployeeID, FirstName, LastName,
Title FROM Employees WHERE EmployeeID < 5",
conn);
da.Fill(ds, "Employees");
conn.Close();
}
}
}
In the next section, we test the events published by the Replica Repeater server control we
created in this chapter.
Advanced Interaction with the Repeater Control
The previous web form demonstrates that our Repeater control is capable of binding to a variety
of data sources.
Pages:
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432