1. 程式人生 > >關於DataGrid控制元件中的自動編號

關於DataGrid控制元件中的自動編號

在此處放置使用者程式碼以初始化頁面
if(!IsPostBack)
this.BindData();
}

private void BindData()
{
SqlConnection cn = new SqlConnection("server=(local);database=NorthWind;uid=sa;pwd=");
string [email protected]"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();

}