简单的数据绑定:
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connStr"].ToString()))
{
SqlDataAdapter sda = new SqlDataAdapter("Select * From T_Class Where F_Type='Product' order by F_RootID,F_Orders", conn);
DataSet Ds = new DataSet();
sda.Fill(Ds, "T_Class");
//使用DataSet绑定时,必须同时指明DateMember
this.dataGridView1.DataSource = Ds;
this.dataGridView1.DataMember = "T_Class";
//也可以直接用DataTable来绑定
this.dataGridView1.DataSource = Ds.Tables["T_Class"];
}