How remove records from datagrid in asp.net if condition satisfy

后端 未结 2 1013
梦谈多话
梦谈多话 2021-01-17 06:38

I have a datagrid declare like this in ascx file:



        
2条回答
  •  Happy的楠姐
    2021-01-17 07:24

    You cannot directly filter the IDataReader since it will be read like one by one.

    What you can simply do is load all the data from datareader into DataTable using a Load() method.

    IDataReader rdr = Syntegra.Manufacturing.WMCCM.Companies.Companies.
                      ListCompanies(dgCompanies.CurrentPageIndex, pageSize, CompanyList,
                      CompanyNameStartsWith, ProcessSqlClause, SkillSqlClause, 
                      LocationClause, KeywordSqlClause, User, Status, SearchPortalId, false, 
                      sortColumn, sortDirection);
    DataTable dt = new DataTable();
    dt.(rdr);
    //For filtering all the CompanyID column value not equal to  5
    DataRow[] filteredRows=DataTable.Select("[CompanyID] <> 5 " ); 
    
    dgCompanies.PageSize = pageSize;
    dgCompanies.DataSource = filteredRows;
    dgCompanies.DataBind();
    

提交回复
热议问题