• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1204
  • Last Modified:

gridview paging does not work

I have two grid viewson my page. I have set AutoPostBack="true" EnableViewState="true" AllowPaging="true" for both of them. They show the page numbers on the bottom of the grid, but when I click on another page number I get this error:
"
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
"
I added the following text to the @Page :
validateRequest="false" enableEventValidation="false"

Now the error is gone but I still cannot navigate through pages on any of my grids.

Pleas check my code and suggest corrections.

Thanks.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" MasterPageFile="Global.master"
    Inherits="_Default" EnableViewState = "true" validateRequest="false" enableEventValidation="false" %>
.......
........

<div class = "caseHistory"><p>      
<asp:UpdatePanel runat="server" ID="UpdatePanel2" ChildrenAsTriggers="false" UpdateMode="Conditional">
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="_Search" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="_SubmitCategory" EventName="Click" />
                </Triggers>
                <ContentTemplate>                                                           
                        <h1><asp:Label ID="CaseHistoryHeader" runat="server" Text="Case History"></asp:Label></h1>
                        <asp:GridView ID="gvCaseHistory" runat="server" 
                        EmptyDataText="No History" AutoGenerateColumns="true"
                            AutoPostBack="true" EnableViewState="true" 
                            AllowPaging="true" PageSize="5" CssClass="mGrid"
                            PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt"
                            OnPageIndexChanging="gvCaseHistory_PageIndexChanging">
                            <PagerSettings Position="Bottom" Mode="NumericFirstLast" 
                                FirstPageText="First" LastPageText="Last"
                                NextPageText="Next" PreviousPageText="Prev" />
                            <PagerStyle HorizontalAlign="Center" />
                        </asp:GridView>                                         
                </ContentTemplate>
                </asp:UpdatePanel>
                </p></div>  
....................
.........................
<div>
                    <asp:UpdatePanel runat="server" ID="UpdatePanel3" ChildrenAsTriggers="false" UpdateMode="Conditional">
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="TimerCaseQueueRefresh" EventName="Tick" />
                            <asp:AsyncPostBackTrigger ControlID="_SubmitCategory" EventName="Click" />
                            <asp:PostBackTrigger ControlID="TextBoxFilter" />
                        </Triggers>
                        <ContentTemplate>                                

                            <asp:GridView ID="gvCaseQueue" runat="server" 
                                AutoPostBack="true" EnableViewState="true"                                
                                EmptyDataText="No Cases Found" CssClass="mGrid"
                                AlternatingRowStyle-CssClass="alt"
                                AutoGenerateColumns="False" 
                                AllowPaging="true" PageSize="20"
                                PagerStyle-CssClass="pgr"                                
                                PagerSettings-Position="Bottom" PagerStyle-HorizontalAlign="Center" 
                                DataSourceID="SqlDataSourceCaseQueue"
                                OnPageIndexChanging="gvCaseQueue_PageIndexChanging">
                                <PagerSettings Position="Bottom" Mode="NumericFirstLast" FirstPageText="First" LastPageText="Last"
                                    NextPageText="Next" PreviousPageText="Prev" />
                                <PagerStyle HorizontalAlign="Center" />
                                <Columns>
                                    <asp:TemplateField HeaderText="Case Queue">
                                        <ItemStyle HorizontalAlign="Center" />
                                        <ItemTemplate>
                                            <a name='<%# Eval("CaseNo") %>' href='Default.aspx?CaseNo=<%# Eval("CaseNo") %>'>
                                                <%# Eval("CaseNo") %></a>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Case Queue">
                                        <ItemStyle HorizontalAlign="Center" />
                                        <ItemTemplate>
                                            <%# Eval("SpecimenType")%>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                            <asp:SqlDataSource ID="SqlDataSourceCaseQueue" runat="server" ConnectionString='<%$ ConnectionStrings:CSICustom %>'
                                SelectCommand="CytoStats.Get_Case_Queue" SelectCommandType="StoredProcedure"
                                FilterExpression="SpecimenType like '{0}%'">
                                <FilterParameters>
                                    <asp:ControlParameter Name="SpecimenType" ControlID="TextBoxFilter" PropertyName="Text"
                                        ConvertEmptyStringToNull="true" />
                                </FilterParameters>
                            </asp:SqlDataSource>                                       
                      </ContentTemplate>
                    </asp:UpdatePanel>
                </div>

Open in new window

0
patd1
Asked:
patd1
  • 3
  • 2
1 Solution
 
Jini Jose.Net Team LeadCommented:
firstly remove the update panel and then try.
you will get the correct error details.
after rectifying the error add the updatepanel
0
 
patd1Author Commented:
Paging works if I remove the UpdatePanel. But I need it on the gvCaseQueue because it has to refresh itself on a timer.

I tried setting ChildrenAsTriggers="true" for and the paging works now. :)

However, if I remove validateRequest="false" enableEventValidation="false" from @Page tag, it still gives the same error. Any ideas what are the implications of this code?

Thanks.
0
 
Jini Jose.Net Team LeadCommented:
if it works fine without updatepanel then it should work with updatepanel.
0
 
Jini Jose.Net Team LeadCommented:
also please check where you calling the bind grid function. is it inside the page post back ?

also in the page change event, did you bind it again ?
0
 
patd1Author Commented:
I tried setting ChildrenAsTriggers="true"
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now