Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 4th, 2004, 08:43 AM
Registered User
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagrid - paging

When autogeneratecolumns=true, paging works fine but the columns displayed are not what I want.

When autogeneratecolumns=false, the wgWellLog_PageIndexChanged event handler is never invoked and the "next page" is blank.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using adminServices = FCS.BeaconResources.AdminServices.clsAdminServices ;
using dbServices = FCS.BeaconResources.WellLogDBServices.WellLogDBSer vices;

namespace FCS.BeaconResources
    /// <summary>
    /// Summary description for DisplayWellData.
    /// </summary>
    public class DisplayWellData : System.Web.UI.Page
        protected System.Web.UI.WebControls.DataGrid dgWellLog;
        public DataSet leDS;
          enum DGCol :int
        private void Page_Load(object sender, System.EventArgs e)
            if (Session["LoggedIn"] == null)
                Session.Add("LoggedIn", false);
            if ((bool)Session["LoggedIn"])
                bool IsSiteDown;
                string SiteMessage;
                new adminServices().SiteStateGet(out IsSiteDown,out SiteMessage);
                    if (!IsPostBack)

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
          this.dgWellLog.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEvent Handler(this.dgWellLog_PageIndexChanged);
          this.Load += new System.EventHandler(this.Page_Load);

        private BoundColumn CreateNewBoundColumn(string Field, string ColHeader)
            BoundColumn BC = new BoundColumn();
            BC.DataField = Field;
            BC.HeaderText = ColHeader;
            return BC;

        protected void BindData()
            dgWellLog.Columns.Add(CreateNewBoundColumn("MMDD", "Date"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("Time", "Time"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("ChokeS izeText","Choke Size (/64)"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("Tubing Pressure","Tbg PSIG"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("Casing Pressure","Csg PSIG"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("MeterP SIG","Line PSIG"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("MeterD iff","Diff PSIG"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("MeterT emp","Temp"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("Orific eSize","Orif. Size"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("WaterF low","H2O (Bbls)"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("WaterA ccum","H2O Cum (Bbls)"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("OilFlo w","Oil(Bbls)"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("OilAcc um","Oil Cum Bbls)"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("Inject ionRate","Inj Rate (MCFPD)"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("Inject ionCum","Inj Cum (MCF)"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("SalesR ate","Sales Rate (MCFPD)"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("SalesC um","Sales Cum (MCF)"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("Yester daySales","Yesterday Sales (MCF)"));
            dgWellLog.Columns.Add(CreateNewBoundColumn("Remark s","Remarks"));
            foreach (DataGridColumn c in dgWellLog.Columns)

          dbServices DBServices = new dbServices();
          leDS = DBServices.LogEntriesGet(((clsWorkOrder)Session["WorkOrder"]).WorkOrder_Key);
          DataColumn dc = new DataColumn("WaterAccum",System.Type.GetType("Syste m.Double"));
          dc = new DataColumn("OilAccum",System.Type.GetType("System. Double"));
          dc = new DataColumn("MMDD",System.Type.GetType("System.Stri ng"));
          dc = new DataColumn("Time",System.Type.GetType("System.Stri ng"));
          dc = new DataColumn("ChokeSizeText",System.Type.GetType("Sy stem.String"));
          double mOilCum = 0;
          double mWaterCum = 0;
          foreach (DataRow r in leDS.Tables["tblLogEntries"].Rows)
            int CS = (int)((double)r["ChokeSize"]);
            switch (CS)
            case -1:
              r["ChokeSizeText"] = "ShtIn";
            case 192:
              r["ChokeSizeText"] = "WidOpn";
              r["ChokeSizeText"] = ((double)r["ChokeSize"]).ToString();

            r["MMDD"] = ((DateTime)r["DateAndTime"]).ToString("MM/dd");
            r["Time"] = ((DateTime)r["DateAndTime"]).ToString("HH:mm");
            mWaterCum += (double)r["WaterFlow"];
            r["WaterAccum"] = mWaterCum;
            mOilCum += (double)r["OilFlow"];
            r["OilAccum"] = mOilCum;

      private void dgWellLog_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
        dgWellLog.CurrentPageIndex = e.NewPageIndex;


Old December 5th, 2004, 09:50 PM
Friend of Wrox
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post


   Post it under .NET forum. This is classic ASP.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom paging in Datagrid with datagrid page count madhusrp ASP.NET 1.0 and 1.1 Professional 12 June 2nd, 2008 01:15 PM
Paging in DataGrid vijay_83 ASP.NET 2.0 Professional 0 September 29th, 2006 02:02 PM
datagrid-paging kvanchi ASP.NET 1.0 and 1.1 Basics 2 December 8th, 2004 04:17 AM
Paging in datagrid Renu ASP.NET 1.0 and 1.1 Basics 2 September 9th, 2004 01:11 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.