开发快速打印按钮

时间:2014-07-24 13:48:12

标签: c# asp.net devexpress

HI有一个开发快递网格13.2如何让用户打印网格?想打印----------或通过导出到excel。

    using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGridView;
using DevExpress.Web.ASPxTreeView;
using FDB.Base;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//* --------------------------------------------------------------------------
namespace FDB.Views
{
    public partial class Interchange : BasePage
    {
        #region Properties

        public string ID_KEY
        {
            get
            {
                if (hfCommon.Contains("ID_KEY"))
                    return hfCommon.Get("ID_KEY").ToString();
                else
                    return "";
            }
            set
            {
                if (hfCommon.Contains("ID_KEY"))
                    hfCommon.Set("ID_KEY", value);
                else
                    hfCommon.Add("ID_KEY", value);
            }
        }

        public decimal SEQNO
        {
            get
            {
                if (hfCommon.Contains("SEQNO"))
                    return hfCommon.Get("SEQNO").ToDecimal();
                else
                    return 0;
            }
            set
            {
                if (hfCommon.Contains("SEQNO"))
                    hfCommon.Set("SEQNO", value);
                else
                    hfCommon.Add("SEQNO", value);
            }
        }
//* --------------------------------------------------------------------------
        public int STAT
        {
            get
            {
                if (hfCommon.Contains("STAT"))
                    return hfCommon.Get("STAT").ToInt();
                else
                    return 0;
            }
            set
            {
                if (hfCommon.Contains("STAT"))
                    hfCommon.Set("STAT", value);
                else
                    hfCommon.Add("STAT", value);
            }
        }
//* --------------------------------------------------------------------------
        public string NDC
        {
            get
            {
                if (hfCommon.Contains("NDC"))
                    return hfCommon.Get("NDC").ToString();
                else
                    return "";
            }
            set
            {
                if (hfCommon.Contains("NDC"))
                    hfCommon.Set("NDC", value);
                else
                    hfCommon.Add("NDC", value);
            }
        }

        public string Reason
        {
            get
            {
                if (hfCommon.Contains("Reason"))
                    return hfCommon.Get("Reason").ToString();
                else
                    return "";
            }
            set
            {
                if (hfCommon.Contains("Reason"))
                    hfCommon.Set("Reason", value);
                else
                    hfCommon.Add("Reason", value);
            }
        }

        public string ReasonText
        {
            get
            {
                if (hfCommon.Contains("ReasonText"))
                    return hfCommon.Get("ReasonText").ToString();
                else
                    return "";
            }
            set
            {
                if (hfCommon.Contains("ReasonText"))
                    hfCommon.Set("ReasonText", value);
                else
                    hfCommon.Add("ReasonText", value);
            }
        }

        public bool OnClickonShowData
        {
            get
            {
                if (hfCommon.Contains("OnClickonShowData"))
                    return hfCommon.Get("OnClickonShowData").ToBoolean();
                else
                    return false;
            }
            set
            {
                if (hfCommon.Contains("OnClickonShowData"))
                    hfCommon.Set("OnClickonShowData", value);
                else
                    hfCommon.Add("OnClickonShowData", value);
            }
        }



        public bool ShowHideFilter
        {
            get
            {
                if (hfCommon.Contains("ShowHideFilter"))
                    return hfCommon.Get("ShowHideFilter").ToBoolean();
                else
                    return false;
            }
            set
            {
                if (hfCommon.Contains("ShowHideFilter"))
                    hfCommon.Set("ShowHideFilter", value);
                else
                    hfCommon.Add("ShowHideFilter", value);
            }
        }

        #endregion

        #region Events

        protected void Page_Load(object sender, EventArgs e)
        {
            FDB.Enums.UserType userType = (FDB.Enums.UserType)Session["UserType"];
            this.gvPBMCharges.HtmlRowCreated += gvPBMCharges_HtmlRowCreated;
            this.gvPBMCharges.CustomCallback += gvPBMCharges_CustomCallback;
            this.gvPBMCharges.HtmlRowPrepared += gvPBMCharges_HtmlRowPrepared;
            this.gvPBMCharges.EnableRowsCache = false;

            ChckLogin();
            LoadTitle();
            PopulateFacilityList();

            if (!IsPostBack && !IsCallback)
            {
                this.OnClickonShowData = false;
                //SelectAllNodes();
                if (userType != Enums.UserType.Admin_User)
                {
                    chkSelectAll.Checked = true;
                    cblFacility.SelectAll();

// * -------------------------------------------- ------------------------------

1 个答案:

答案 0 :(得分:0)

您应该使用ASPxGridViewExporter - DevExpress提供的特殊组件来支持将ASPxGridView导出为不同的格式。它的用法非常清楚,并在以下文档中解释:ASPxGridViewExporter。要将ASPxGridView导出到Excel,您需要使用以下方法中的任何一个:

WriteXls,WriteXlsToResponse,WriteXlsx,WriteXlsxToResponse。所有这些都在这里描述:

Documenation