[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

gridview paging does not work

Posted on 2011-03-02
5
Medium Priority
?
1,196 Views
Last Modified: 2012-05-11
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
Comment
Question by:patd1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:Jini Jose
ID: 35024086
firstly remove the update panel and then try.
you will get the correct error details.
after rectifying the error add the updatepanel
0
 

Accepted Solution

by:
patd1 earned 0 total points
ID: 35027535
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
 
LVL 10

Expert Comment

by:Jini Jose
ID: 35028167
if it works fine without updatepanel then it should work with updatepanel.
0
 
LVL 10

Expert Comment

by:Jini Jose
ID: 35028180
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
 

Author Closing Comment

by:patd1
ID: 35187357
I tried setting ChildrenAsTriggers="true"
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question