Datawindow.net 系列五

系列 五--讲述page的分页
可以看看实现的效果图
CheckBox:Show Page Info------show or hide Page total information
DropDownList:Place-----show page navigation top , bottom or topbottom
ChekBox:Image Navigation---determine whether use arrow image or not
DropDownList:Page Type----determine use whick page navigation :NextPrev,NextPrevWithQuickGo,Numeric, NumericWithQuickGo, QuickGo
DropDownList:Goto Page Type:---quick go type:edit or dropdownlist(hide)

aspx code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="demo002.aspx.cs" Inherits="itwms.page.demo002" %>
<%@ Register Assembly="WebDataWindow" Namespace="Sybase.DataWindow.Web" TagPrefix="dw" %>


    DataWindow.Net Page Demo


   

   

       
       
       
         
       

       
           
               
           

       

       

       
       
         
       
       
            Top
            Bottom
            TopBottom
       

       
            NextPrev
            NextPrevWithQuickGo
            Numeric
            NumericWithQuickGo
            QuickGo
       

         
       
            Edit
            DropDowList
       

   


cs code:


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace itwms.page
{
    public partial class demo002 : System.Web.UI.Page
    {
        private Sybase.DataWindow.Transaction Trans;
        private System.ComponentModel.IContainer container;
        protected void Page_Load(object sender, EventArgs e)
        {
            InitializeComponent();
            //if (!IsPostBack)
            //{
            //    Trans.Connect();
            //    webDWcntrl.SetTransaction(Trans);
            //    webDWcntrl.Retrieve();
            //}
        }
        private void InitializeComponent()
        {
            container = new System.ComponentModel.Container();
            Trans = new Sybase.DataWindow.Transaction(container);
            Trans.Dbms = Sybase.DataWindow.DbmsType.OleDb;
            Trans.Password = "password";
            Trans.UserId = "sa";
            Trans.AutoCommit = false;
            Trans.Lock = "RC";
            Trans.DbParameter = "PROVIDER='SQLOLEDB',DATASOURCE='server',PROVIDERSTRING='database=Northwind'";
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            webDWcntrl.Visible = true;
            Trans.Connect();
            webDWcntrl.SetTransaction(Trans);
            webDWcntrl.Retrieve();
            setProperties();
        }
        private void setProperties()
        {
            if (pageInfoCheckBox.Checked)
            {
                webDWcntrl.PageNavigationBarSettings.PageStatusInfo.Visible = true;
                webDWcntrl.PageNavigationBarSettings.PageStatusInfo.Position = Sybase.DataWindow.Web.PageStatusInfoPosition.Right;
            }
            else
            {
                webDWcntrl.PageNavigationBarSettings.PageStatusInfo.Visible = false;
            }
            switch (placeDropDownList.SelectedIndex)
            {
                case 0:
                    webDWcntrl.PageNavigationBarSettings.Position = Sybase.DataWindow.Web.NavigationBarPosition.Top;
                    break;
                case 1:
                    webDWcntrl.PageNavigationBarSettings.Position = Sybase.DataWindow.Web.NavigationBarPosition.Bottom;
                    break;
                case 2:
                    webDWcntrl.PageNavigationBarSettings.Position = Sybase.DataWindow.Web.NavigationBarPosition.TopAndBottom;
                    break;
                default:
                    goto case 1;
            }
            if (imageCheckBox.Checked)
            {
                webDWcntrl.PageNavigationBarSettings.NextPrevNavigator.FirstPageImageUrl = Page.Server.MapPath("../image/PageFirst.gif");
                webDWcntrl.PageNavigationBarSettings.NextPrevNavigator.PrevPageImageUrl = Page.Server.MapPath("../image/PagePrior.gif");
                webDWcntrl.PageNavigationBarSettings.NextPrevNavigator.NextPageImageUrl = Page.Server.MapPath("../image/PageNext.gif");
                webDWcntrl.PageNavigationBarSettings.NextPrevNavigator.LastPageImageUrl = Page.Server.MapPath("../image/PageLast.gif");
            }
            else
            {
                webDWcntrl.PageNavigationBarSettings.NextPrevNavigator.FirstPageImageUrl = "";
                webDWcntrl.PageNavigationBarSettings.NextPrevNavigator.PrevPageImageUrl = "";
                webDWcntrl.PageNavigationBarSettings.NextPrevNavigator.NextPageImageUrl = "";
                webDWcntrl.PageNavigationBarSettings.NextPrevNavigator.LastPageImageUrl = "";
            }
            switch (typeDropDownList.SelectedIndex)
            {
                case 0:
                    webDWcntrl.PageNavigationBarSettings.NavigatorType = Sybase.DataWindow.Web.PageNavigatorType.NextPrev;
                    break;
                case 1:
                    webDWcntrl.PageNavigationBarSettings.NavigatorType = Sybase.DataWindow.Web.PageNavigatorType.NextPrevWithQuickGo;
                    break;
                case 2:
                    webDWcntrl.PageNavigationBarSettings.NavigatorType = Sybase.DataWindow.Web.PageNavigatorType.Numeric;
                    break;
                case 3:
                    webDWcntrl.PageNavigationBarSettings.NavigatorType = Sybase.DataWindow.Web.PageNavigatorType.NumericWithQuickGo;
                    break;
                case 4:
                    webDWcntrl.PageNavigationBarSettings.NavigatorType = Sybase.DataWindow.Web.PageNavigatorType.QuickGo;
                    break;
                default:
                    goto case 0;
            }
            if (typeDropDownList.SelectedIndex.Equals(4))
            {
                switch (gotoPageTypeDropDownList.SelectedIndex)
                {
                    case 0:
                        webDWcntrl.PageNavigationBarSettings.QuickGoNavigator.Type = Sybase.DataWindow.Web.QuickGoPageNavigatorType.Edit;
                        break;
                    case 1:
                        webDWcntrl.PageNavigationBarSettings.QuickGoNavigator.Type = Sybase.DataWindow.Web.QuickGoPageNavigatorType.DropDownList;
                        break;
                }
            }
        }
        protected void typeDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            imageCheckBox.Visible = true;
            switch (typeDropDownList.SelectedIndex)
            {
                case 2:
                    goto case 3;
                case 4:
                    gotoPageTypeDropDownList.Visible = true;
                    gotoPageTypeLabel.Visible = true;
                    goto case 3;
                case 3:
                    imageCheckBox.Checked = false;
                    imageCheckBox.Visible = false;
                    break;
            }
        }
    }
}

当然这些,是通过code实现的,因为我为了页面实现多种分页方式,下面介绍一下,属性设置某一种分页方式:
如图:
Datawindow.net 系列五_第1张图片
我们可以随意设置,几个需要强调的地方:
a,RowsPerPage不能为0;
b,各自对应的visible不要忘记;
全部系列相关链接:
Datawindow.net系列之一
Datawindow.net系列之二
Datawindow.net系列之三
Datawindow.net系列之四
Datawindow.net系列之五
Datawindow.net系列之六
Datawindow.net系列之七
Datawindow.net系列之八
Datawindow.net系列之九
返回到本系列首页--Datawindow.net系列之一

你可能感兴趣的:(.NET,相关,Power,Builder)