我有一个数据集,在数据集中我有两个功能:
GetDataMenuPagin(@PageIndex, @PageSize)
SP_GetCountMenuDataPagin()
我从名为“Menu”的表中获取1500条记录的数据。我设置的页面大小是10,所以总页面必须是150页。但我如何设置pagingtoolbar的总数?
这是我的对象数据源&存储,我使用数据集:
<asp:ObjectDataSource ID="MenuDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetDataMenuPagin" EnablePaging="false"
TypeName="dsHorizonTableAdapters.MenuTableAdapter" OnUpdating="MenuDataSourceUpdating"
DataObjectTypeName="System.Guid" DeleteMethod="Delete" InsertMethod="Insert"
OnSelecting="MenuDataSource_Selecting">
<InsertParameters>
<asp:Parameter DbType="Guid" Name="Id" />
<asp:Parameter DbType="Guid" Name="ParentMenuId" />
<asp:Parameter DbType="Guid" Name="PageId" />
<asp:Parameter Name="Criteria" Type="String" />
<asp:Parameter Name="Display" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="MenuURL" Type="String" />
<asp:Parameter Name="Sort" Type="String" />
<asp:Parameter Name="IsActive" Type="Boolean" />
<asp:Parameter Name="UpdateDate" Type="DateTime" />
<asp:Parameter Name="UpdateUser" Type="String" />
<asp:Parameter DbType="Guid" Name="MethodId" />
<asp:Parameter Name="Image" Type="String" />
<asp:Parameter DbType="Guid" Name="ProgramId" />
<asp:Parameter DbType="Guid" Name="StatusId" />
</InsertParameters>
<SelectParameters>
<asp:Parameter DefaultValue="0" Name="PageIndex" Type="Int32" />
<asp:Parameter DefaultValue="10" Name="PageSize" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<ext:Store ID="MenuStore" runat="server" DataSourceID="MenuDataSource" AutoDataBind="false"
AutoLoad="false" onrefreshdata="MenuStore_RefreshData">
<Reader>
<ext:JsonReader IDProperty="Id" AutoDataBind="True">
<Fields>
<ext:RecordField Name="Id" />
<ext:RecordField Name="ParentMenuId" />
<ext:RecordField Name="PageId" />
<ext:RecordField Name="Criteria" />
<ext:RecordField Name="Display" />
<ext:RecordField Name="Description" />
<ext:RecordField Name="MenuURL" />
<ext:RecordField Name="IsActive" DefaultValue="true" />
<ext:RecordField Name="Sort" DefaultValue="0" />
<ext:RecordField Name="UpdateDate" Type="Date" />
<ext:RecordField Name="UpdateUser" />
<ext:RecordField Name="ParentMenuDisplay" />
<ext:RecordField Name="PageDisplay" />
</Fields>
</ext:JsonReader>
</Reader>
<Listeners>
<LoadException Handler="Ext.Msg.Alert('Column - Load failed', e.message || e )" />
<CommitFailed Handler="Ext.Msg.Alert('Column - Commit failed', 'Reason: ' + msg)" />
<SaveException Handler="Ext.Msg.Alert('Column - Save failed', e.message || e)" />
<CommitDone Handler="Ext.Msg.Alert('Column - Commit', 'The data successfully saved');" />
</Listeners>
</ext:Store>
答案 0 :(得分:0)
所以我有以下内容,我正在使用VB,但我确信你可以将它转换为C#
在“SelectParameters”中,我还有一个名为“TotalPages”,看起来像这样
<ext:Parameter Name="TotalPages" Type="Int32" Direction="Output" />
在你的GetDataMenuPagin方法中应该看起来像......
Public Shared Function GetDataMenduPagin(ByVal PageIndex As Int32, ByVal PageSize as Int32, ByRef TotalPagesas Int32) As List(Of xxxxx)
Dim res = (from i in db.my_table _
Select i).Skip(PageIndex).Take(PageSize)
TotalPages = res.Count()
Return res.ToList()
End Function
正如您所看到的,我们将TotalPages设置为输出,我们可以将其绑定 只要您指定它是输出参数,您的selectmethod中的数字。
我在C#的某个地方看到了这个例子,但我记不起来了。我今天稍后会仔细检查