0
我有一个Gridview显示来自搜索查询的分页结果。我遇到的问题是gridview没有显示查询返回的所有结果。例如,我可以遍历代码并查看调用GetList()返回的6个项目,但绑定后只有2行由gridview呈现。ASP.NET Gridview不绑定到自定义列表中的所有项目
我正在使用的代码创建一个ObjectDataSource:
ObjectDataSource ods = new ObjectDataSource();
ods.EnablePaging = true;
ods.TypeName = "Bll.InvestmentProductSvc";
ods.DataObjectTypeName = "Bll.InvestmentProduct";
ods.SelectMethod = "GetList";
ods.SelectCountMethod = "GetListCount";
ods.StartRowIndexParameterName = "PageIndex";
ods.MaximumRowsParameterName = "PageSize";
ods.EnableViewState = false;
ods.SelectParameters.Add (new Parameter("SearchString",TypeCode.String, SearchString));
ods.SelectParameters.Add(new Parameter("PageIndex", TypeCode.Int32));
ods.SelectParameters.Add(new Parameter("PageSize", TypeCode.Int32, gvSearchResults.PageSize.ToString()));
gvSearchResults.DataSource = ods;
gvSearchResults.DataBind();
在GridView声明:
<asp:GridView ID="gvSearchResults" runat="server" AutoGenerateColumns="False" AllowPaging="true" PageIndex="0" PageSize="50" OnPageIndexChanging="gvSearchResults_PageIndexChanging" PagerSettings-Position="TopAndBottom">
</asp:GridView>
是否有GridView控件不使行和不报告的任何原因错误? 我检查了6个项目返回的数据,在显示的2行和未显示的4行之间找不到任何显着差异。由归国
谢谢,你钉它!一段时间后,GetListCount()还没有更新,导致结果不一致。 – HectorMac 2010-06-23 14:13:15