您的位置:首页 > 其它

Linq to DataTable 操作

2016-09-01 17:46 375 查看
--- 绑定显示列表   private void BindList()        {            DataTable dt = dal.GetList("");   // GetList("") 方法从数据库读取并返回DataTable对象集合            string args = "";     //查询参数            if (!string.IsNullOrEmpty(this.txtvalue.Text))   // 判断文本框输入查询条件            {                args = this.txtvalue.Text.ToString();            }            var vdt = from temp in dt.AsEnumerable()      // linq语句                        where temp["CompanyName"].ToString().StartsWith(args)                      select new                      {  // 集合列表Eval()方法绑定的显示字段;                          Comid = temp["Comid"].ToString(),                          CompanyName = temp["CompanyName"].ToString(),                          NCID = temp["NCID"].ToString(),                          CreateDate = temp["CreateDate"].ToString(),                          Phone = temp["Phone"].ToString()                      };            this.Repeater1.DataSource = vdt;            this.Repeater1.DataBind();        }----以上的操作完全在aspx.cs的前台页面中的后台页面中书写的,但我不清楚到底在前台写linq绑定号还是在 dal数据层写好.欢迎各位dX歇息
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: