0

i have a dataset, in dataset i have two function : GetDataMenuPagin(@PageIndex, @PageSize) SP_GetCountMenuDataPagin() I get data from a table named "Menu" with 1500 record. I set page size is 10, so total page must be 150 page. But how i can set total for pagingtoolbar ?

This is my object data source & store , i using dataset:

<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>
Jay Riggs
  • 53,046
  • 9
  • 139
  • 151
Thanh Le
  • 235
  • 1
  • 3
  • 15

1 Answers1

0

So what I have is the following, I'm using VB but I'm sure that you can just convert this to C#

Within the "SelectParameters" I have one more called "TotalPages" that looks like this

<ext:Parameter Name="TotalPages" Type="Int32" Direction="Output" />

Within your GetDataMenuPagin method should look something along the lines of...

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 

As you can see, we are setting TotalPages as an output, with that we can bind the number within your selectmethod as long as you specify that it is an output parameter.

I saw this example somewhere in C# but, I can't remember where. I will double check this later on today

Yesuah
  • 1