zoukankan      html  css  js  c++  java
  • 关于Linq to DataSet

    代码
      private PagedDataSource BindMethod(PagedDataSource pds, string keyword)
            {
                OthersTradeBo bo 
    = null;
                
    try
                {
                    bo 
    = new OthersTradeBo();
                    DataSet ds 
    = responseDataSet(bo);
                    DataTable dt 
    = ds.Tables[0];
                    
    //空白时候,搜索全部
                    if (string.IsNullOrEmpty(keyword))
                    {
                        DataView dv 
    = ds.Tables[0].DefaultView; 
                        pds.DataSource 
    = dv;//视图用于绑定到页面
                        _recordCount = ds.Tables[0].DefaultView.Count;
                    }
                    
    else
                    {
                        var temp 
    = from c in dt.AsEnumerable() where c.Field<String>("InformationTitle").Contains(keyword) select c;
                        
    //dt.AsEnumerable().Where(c => c.Field<String>("InformationTitle").Contains(keyword));  //另外的写法,效果一样
                        pds.DataSource = temp.AsDataView();
                        _recordCount 
    = temp.Count();
                    }
                    bindPageButtons(_recordCount, _pagesize);
                    
    return pds;
                }
                
    finally { if (bo != null)bo.Dispose(); }
            }

    其中代码片段。

  • 相关阅读:
    windows系统中ubuntu虚拟机安装及web项目到服务上(二)
    windows系统中ubuntu虚拟机安装及web项目到服务上(一)
    每个配置xml的含义作用
    第三天气接口使用总结
    js模式学习
    mac下php环境配置
    struts2
    MySQL常用命令
    JavaMail邮件开发
    文件上传与下载
  • 原文地址:https://www.cnblogs.com/drek_blog/p/1709939.html
Copyright © 2011-2022 走看看