private int rowscount = 0;
protected int RowsCount
{
get{ return rowscount;}
set{ this.rowscount = value; }
}
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
this.BindData();
}
private void BindData()
{
SqlConnection cn = new SqlConnection("server=(local);database=NorthWind;uid=sa;pwd=");
string str=@"SELECT Employees.EmployeeID, Orders.EmployeeID
FROM Employees INNER JOIN
Orders ON Employees.EmployeeID = Orders.EmployeeID ";
SqlDataAdapter sqlda = new SqlDataAdapter(str,cn);
DataSet ds = new DataSet();
sqlda.Fill(ds);
this.RowsCount = ds.Tables[0].Rows.Count;
this.DataGrid1.DataSource = ds;
this.DataGrid1.DataBind();
} |