查找DataTable中的DataRow
            DataRow dr = dt.Rows.Find(gv.DataKeys[e.RowIndex]["id"].ToString());
            dr["flag"] = "0";

Linq

                IEnumerable<DataRow> q = from dr in dt.AsEnumerable()
                                         where dr.Field<int>("id").ToString() == gv.DataKeys[i]["id"].ToString()
                                         select dr;
                foreach (DataRow dr in q)
                    dr["flag"] = "0";

Lambda

IEnumerable<DataRow> q = dt.AsEnumerable().Where<DataRow>(r => (r.Field<int>("id").ToString() == gv.DataKeys[e.RowIndex]["id"].ToString()));
            foreach (DataRow dr in q)
                dr["flag"] = "0";

匿名方法

IEnumerable<DataRow> q = dt.AsEnumerable().Where<DataRow>(delegate(DataRow r) { return r["id"].ToString() == gv.DataKeys[i]["id"].ToString(); });
                    foreach (DataRow dr in q) 
                        dr["flag"] = "0";
posted on 2011-06-29 11:17  pchgo  阅读(2186)  评论(0编辑  收藏  举报