开发者

ASP.Net GridView UpdatePanel Paging Gives Error On Second Click

I'm trying to implement a GridView with paging inside a UpdatePanel. Everything works great when I do my first click. The paging kicks in and the next set of data is loaded quickly. However, when I then try to click a link for another page of data, I get the following error:

Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code ret开发者_运维问答urned from the server was: 12030

aspx code

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <contenttemplate>
        <asp:GridView ID="GridView1" runat="server" CellPadding="2" 
                AllowPaging="true" AllowSorting="true" PageSize="20"
                OnPageIndexChanging="GridView1_PageIndexChanging"
                OnSorting="GridView1_PageSorting"
                AutoGenerateColumns="False">
            <Columns>
                <asp:BoundField DataField="ActivityLogID" HeaderText="Activity Log ID" SortExpression="ActivityLogID" />
                <asp:BoundField DataField="ActivityDate" HeaderText="Activity Date" SortExpression="ActivityDate" />
                <asp:BoundField DataField="ntUserID" HeaderText="NTUserID" SortExpression="ntUserID" />
                <asp:BoundField DataField="ActivityStatus" HeaderText="Activity Status" SortExpression="ActivityStatus" />
            </Columns>
        </asp:GridView>
    </contenttemplate>
</asp:UpdatePanel>

code behind

    private void bindGridView(string sortExp, string sortDir)
    {
        SqlCommand mySqlCommand = new SqlCommand(sSQL, mySQLconnection);
        SqlDataAdapter mySqlAdapter = new SqlDataAdapter(mySqlCommand);
        mySqlAdapter.Fill(dtDataTable);

        DataView myDataView = new DataView();
        myDataView = dt.DefaultView;

        if (sortExp != string.Empty)
        {
            myDataView.Sort = string.Format("{0} {1}", sortExp, sortDir);
        }

        GridView1.DataSource = myDataView;
        GridView1.DataBind();

        if (mySQLconnection.State == ConnectionState.Open)
        {
            mySQLconnection.Close();
        }

    }
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        bindGridView();
    }
    protected void GridView1_PageSorting(object sender, GridViewSortEventArgs e)
    {

        bindGridView(e.SortExpression, sortOrder);

    }

any clues on what is causing the error on the second click?


If anything on your page that is outside UpdatePanel, is changing after the first click, or try to change, on second click is comething diferent, but your calls did get again the fist one value because there are outside UpdatePanel and did not get the update value, just get the first one again -> So product an error on second click.

Probably you have out side the UpdatePanel some data thats need to be rendered correctly. Keep inside UpdatePanel anything that you change and use with this control.

For example the sSQL, where do you store it ? Its change ? Maybe other value changes on click ?


Probably you have out side the UpdatePanel some data thats need to be rendered correctly. Keep inside UpdatePanel anything that you change and use with this control.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜