void Page_Load(object sender, System.EventArgs e)
{
// create the connection, DataAdapter and DataSet
string connString = "server=(local);database=Northwind;uid=sa;pwd=zsb007;";
string sql = "SELECT * FROM Employees";
SqlConnection conn = new SqlConnection(connString);
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
// fill the DataSet
da.Fill(ds, "Employees");
// bind the DataSet to the repeater
Repeater1.DataSource = ds;
Repeater1.DataMember = "Employees";
Repeater1.DataBind();
// cycle through the records, and build the HTML string
StringBuilder htmlStr = new StringBuilder("");
foreach (DataRow dr in ds.Tables["Employees"].Rows)
{
htmlStr.Append("<li>");
htmlStr.Append(dr["TitleOfCourtesy"].ToString());
htmlStr.Append(" <b>");
htmlStr.Append(dr["LastName"].ToString());
htmlStr.Append("</b>, ");
htmlStr.Append(dr["FirstName"].ToString());
htmlStr.Append("</li>");
}
// show the generated HTML code
HtmlContent.Text = htmlStr.ToString();
}