Paging Gridview in HttpHandler RRS feed

  • Question

  • User-852409647 posted
    How do I support paging with a GridView in an HttpHandler? 

          <add verb="POST,GET,HEAD" path="Report.aspx" type="ErrorAudit.Report"/>

    I've only managed to render the gridview w/o its paging:

    namespace ErrorAudit
        class Report : System.Web.UI.Page
            protected string connectionString;
            protected System.Web.UI.WebControls.GridView GridViewReport;

            public override void ProcessRequest(HttpContext context)
                connectionString = ConfigurationManager.ConnectionStrings["mxlerrlog"].ConnectionString;
                    throw (new NullReferenceException("ConnectionString configuration is missing from you web.config."));

            protected override void Render(System.Web.UI.HtmlTextWriter writer)
                string includeTemplate = "<link rel='stylesheet' text='text/css' href='{0}' />";
                string includeLocation = Page.ClientScript.GetWebResourceUrl(this.GetType(), "ErrorAudit.Stylesheet.css");
                writer.Write(String.Format(includeTemplate, includeLocation));

                writer.Write("</head><body><form id=\"form1\" runat=\"server\">");

                // cut out blah blah filling dataset
                DataSet ds = new DataSet("Errors");

                GridViewReport = new GridView();
                GridViewReport.CssClass = "adm";
                GridViewReport.DataSource = ds;
                GridViewReport.AllowPaging = true;
                GridViewReport.AllowSorting = true;
                GridViewReport.PageSize = 10;

    Wednesday, January 25, 2006 2:32 AM

All replies

  • User-1391363652 posted
    You're playing with something dangerous here. Traditionally, grid controls have heavily relied on view state, wich you are nuking in this case. I suggest you develop a composite control instead, abandon your idea of an HttpHandler and look into the GridView.EnableSortingAndPagingCallbacks property.
    Wednesday, January 25, 2006 3:16 PM
  • User-852409647 posted
    Thanks.  I will give the Callbacks a shot.  Why do I have to give up the idea of an HttpHandler?  I'm working on an error logging httpmodule/error viewing httphandler similar in principle to Elmah.  I like the idea of an HttpHandler so I can plug it into a project via web.config and not have to worry about recompiling the app or messing with its internals to setup an error viewer.
    Thursday, January 26, 2006 2:44 PM