【发布时间】:2010-06-23 12:44:46
【问题描述】:
我有一个显示来自搜索查询的分页结果的 Gridview。我遇到的问题是gridview 没有显示查询返回的所有结果。例如,我可以单步执行代码并查看调用 GetList() 返回的 6 个项目,但绑定后 gridview 只呈现 2 行。
我正在使用在代码中创建的 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 行之间找不到任何明显的差异。
【问题讨论】: