我利用GridView+ObjectDataSource设置GridView的分页显示,后台代码如下:[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
public IQueryable<FruitDroppingSurvey> GetImagoSurveyInfoByView2(int monitoringPointId, string drosophilaType, int maximumRows, int startRowIndex)
{
PestInfoDatabaseModelContainer Entity = new PestInfoDatabaseModelContainer();
IQueryable<FruitDroppingSurvey> _FruitDroppingSurvey_view2 = (from c in Entity.FruitDroppingSurvey
where c.MonitoringPointID == monitoringPointId
where c.DrosophilaType.Equals(drosophilaType)
orderby c.Time,c.SurveyPointID
select c);
return _FruitDroppingSurvey_view2;
} //分页计数;
public int GetCountFruitDroppingSurvey(int monitoringPointId, string drosophilaType, int maximumRows, int startRowIndex)
{
IQueryable<FruitDroppingSurvey> _FruitDroppingSurvey_view2 = (from c in Entity.FruitDroppingSurvey
where c.MonitoringPointID == monitoringPointId
where c.DrosophilaType.Equals(drosophilaType)
orderby c.Time, c.SurveyPointID
select c);
if (_FruitDroppingSurvey_view2!=null)
{
return _FruitDroppingSurvey_view2.Count();
}
else
{
return 0;
}
}然后将GetImagoSurveyInfoByView2绑定到ObjectDataSource,
再设置ObjectDataSource的分页EnablePaging,MaximunRowsParameterName,SelectedCountMethod,StartRowIndexParameterName
再将GridView的AllowPaging设置为True.
上述各项绑定正常,但是在运行的时候,GridView能正常显示,但是数据全部显示在一页,并没有
实现分页???
请赐教,百分百结贴。
public IQueryable<FruitDroppingSurvey> GetImagoSurveyInfoByView2(int monitoringPointId, string drosophilaType, int maximumRows, int startRowIndex)
{
PestInfoDatabaseModelContainer Entity = new PestInfoDatabaseModelContainer();
IQueryable<FruitDroppingSurvey> _FruitDroppingSurvey_view2 = (from c in Entity.FruitDroppingSurvey
where c.MonitoringPointID == monitoringPointId
where c.DrosophilaType.Equals(drosophilaType)
orderby c.Time,c.SurveyPointID
select c);
return _FruitDroppingSurvey_view2;
} //分页计数;
public int GetCountFruitDroppingSurvey(int monitoringPointId, string drosophilaType, int maximumRows, int startRowIndex)
{
IQueryable<FruitDroppingSurvey> _FruitDroppingSurvey_view2 = (from c in Entity.FruitDroppingSurvey
where c.MonitoringPointID == monitoringPointId
where c.DrosophilaType.Equals(drosophilaType)
orderby c.Time, c.SurveyPointID
select c);
if (_FruitDroppingSurvey_view2!=null)
{
return _FruitDroppingSurvey_view2.Count();
}
else
{
return 0;
}
}然后将GetImagoSurveyInfoByView2绑定到ObjectDataSource,
再设置ObjectDataSource的分页EnablePaging,MaximunRowsParameterName,SelectedCountMethod,StartRowIndexParameterName
再将GridView的AllowPaging设置为True.
上述各项绑定正常,但是在运行的时候,GridView能正常显示,但是数据全部显示在一页,并没有
实现分页???
请赐教,百分百结贴。
where c.MonitoringPointID == monitoringPointId
where c.DrosophilaType.Equals(drosophilaType)
where c.Time.Year==year
where c.Time.Month==month
orderby c.Time, c.SurveyPointID
select c)
.Skip(startRowIndex)
.Take(maximumRows);