views:

283

answers:

1

Hi all,

I have a Dynamic data website. I have customized the List page and using SP with custom paging. Custom paging is working fine as expected. The pager is also working fine, if click next page icon in the pager. The problem is, when click the Last page icon in the GridView pager, it takes to the last page and last 10 records are displayed. From the last page when i click previous page icon, the pager just gets cleared off and does nothing. Meaning the pager vanishes from the GridView and last page records are displayed without pager.

<asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="false" />

    <h2><%= table.DisplayName%></h2>

    <asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy1" />

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                HeaderText="List of validation errors" />
            <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" />

            <asp:FilterRepeater ID="FilterRepeater" runat="server">
                <ItemTemplate>
                    <asp:Label runat="server" Text='<%# Eval("DisplayName") %>' AssociatedControlID="DynamicFilter$DropDownList1" />
                    <asp:DynamicFilter runat="server" ID="DynamicFilter" OnSelectedIndexChanged="OnFilterSelectedIndexChanged" />
                </ItemTemplate>
                <FooterTemplate><br /><br /></FooterTemplate>
            </asp:FilterRepeater>

            <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource"
                AllowPaging="True" AllowSorting="True" CssClass="gridview">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:HyperLink ID="EditHyperLink" runat="server"
                                NavigateUrl='<%# table.GetActionPath(PageAction.Edit, GetDataItem()) %>'
                            Text="Edit" />&nbsp;<asp:LinkButton ID="DeleteLinkButton" runat="server" CommandName="Delete"
                                CausesValidation="false" Text="Delete"
                                OnClientClick='return confirm("Are you sure you want to delete this item?");'
                            />&nbsp;<asp:HyperLink ID="DetailsHyperLink" runat="server"
                                NavigateUrl='<%# table.GetActionPath(PageAction.Details, GetDataItem()) %>'
                                Text="Details" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>

                <PagerStyle CssClass="footer"/>        
                <PagerTemplate>
                    <asp:GridViewPager runat="server" />
                </PagerTemplate>
                <EmptyDataTemplate>
                    There are currently no items in this table.
                </EmptyDataTemplate>
            </asp:GridView>

            <asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true" 
                AutoPage="False" onselecting="GridDataSource_Selecting">
                <WhereParameters>
                    <asp:DynamicControlParameter ControlID="FilterRepeater" />
                </WhereParameters>
            </asp:LinqDataSource>

Codebehind,

public partial class List : System.Web.UI.Page {
    protected MetaTable table;

    protected void Page_Init(object sender, EventArgs e) {
        DynamicDataManager1.RegisterControl(GridView1, true /*setSelectionFromUrl*/);
    }

    protected void Page_Load(object sender, EventArgs e) {
        table = GridDataSource.GetTable();
        Title = table.DisplayName;

        InsertHyperLink.NavigateUrl = table.GetActionPath(PageAction.Insert);

        // Disable various options if the table is readonly
        if (table.IsReadOnly) {
            GridView1.Columns[0].Visible = false;
            InsertHyperLink.Visible = false;
        }
    }

    protected void OnFilterSelectedIndexChanged(object sender, EventArgs e) {
        GridView1.PageIndex = 0;
    }
     protected void GridDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    DataClassesDataContext context = new DataClassesDataContext();

    //IMultipleResults results = db.GetContacts(e.Arguments.StartRowIndex, e.Arguments.MaximumRows, e.Arguments.SortExpression, (int?)e.WhereParameters["ContactTypeId"]);
    IMultipleResults results = context.praSearch_Scenario("",new DateTime(2009,3,31),"","",e.Arguments.StartRowIndex, e.Arguments.MaximumRows);
    e.Result = results.GetResult<tbl_Scenario>().ToList();
    e.Arguments.TotalRowCount = results.GetResult<int>().Single<int>();
}

SP:

    [Function(Name="dbo.praSearch_Scenario")]
[ResultType(typeof(tbl_Scenario))]
[ResultType(typeof(int))]
public IMultipleResults praSearch_Scenario([Parameter(Name = "Scenario_No", DbType = "VarChar(50)")] string scenario_No, [Parameter(Name = "Bus_Date", DbType = "Date")] System.Nullable<System.DateTime> bus_Date, [Parameter(Name = "Bus_Line", DbType = "VarChar(50)")] string bus_Line, [Parameter(Name = "Event_Type", DbType = "VarChar(50)")] string event_Type, [Parameter(Name = "StartIndex", DbType = "Int")] System.Nullable<int> startIndex, [Parameter(Name = "MaxRows", DbType = "Int")] System.Nullable<int> maxRows)
    {
     IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), scenario_No, bus_Date, bus_Line, event_Type, startIndex, maxRows);
    return ((IMultipleResults)(result.ReturnValue));
    }

Any help on this will be much appreciated!!!

A: 

I'm having the same problem. Did you find the solution?

Ricardo