public void BindGridView(System.Web.UI.WebControls.GridView gv) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("ID")); dt.Columns.Add(new DataColumn("Name")); dt.Columns.Add(new DataColumn("CreateTime", Type.GetType("System.DateTime"))); DataRow dr = dt.NewRow(); dr["ID"] = "1"; dr["Name"] = "嘿嘿"; dr["CreateTime"] = DateTime.Now.AddDays(1); dt.Rows.Add(dr); DataRow dr1 = dt.NewRow(); dr1["ID"] = "2"; dr1["Name"] = "杨阳"; dr1["CreateTime"] = DateTime.Now.AddHours(1); dt.Rows.Add(dr1); IEnumerable<DataRow> name = from t in dt.AsEnumerable() where t.Field<String>("ID").Equals("1") select t; foreach (var item in name) { Response.Write(item.Field<String>("Name").ToString() + item.Field<DateTime>("CreateTime").ToString()); } var name2 = from t in dt.AsEnumerable().OrderBy(o => o.Field<DateTime>("CreateTime")) select new { Name = t.Field<String>("Name"), ID = t.Field<String>("ID"), Create = t.Field<DateTime>("CreateTime") }; var tblist = (from t in dt.AsEnumerable().OrderBy(o => o.Field<DateTime>("CreateTime")) select t).ToList(); Response.Write(tblist.Count); gv.DataSource = name2; gv.DataBind(); gv.EnableViewState = false; }