Database Reference
In-Depth Information
Figure 16-11.
Running and testing the WebDataForm
How It Works
First you have to add the data access code to
WebDataForm.aspx.cs
, which builds the query and then
loads the data table.
//Query
string query = @" SELECT Title, BirthDate
FROM HumanResources.Employee";
DataTable dt = new DataTable();
After building the data table, you fill the
DataAdapter
object using this
DataTable
object.
try
{
SqlDataAdapter da = new SqlDataAdapter(query, connString);
da.Fill(dt);
}
Next you populate the Repeater control with the data.
//Populate Repeater control with data
RepData.DataSource = dt;
RepData.DataBind();