当前位置: 首页>>代码示例>>C#>>正文


C# GridView.Dispose方法代码示例

本文整理汇总了C#中GridView.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# GridView.Dispose方法的具体用法?C# GridView.Dispose怎么用?C# GridView.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GridView的用法示例。


在下文中一共展示了GridView.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExportDataToExcel

    /// <summary>
    ///  Returns string for a Given Dataset Values
    /// </summary>
    /// <param name="ds"></param>
    /// <param name="exportColumnHeadings"></param>
    public void ExportDataToExcel(string strFileName, GridView gridViewControl)
    {
        Response.Clear();
        Response.ClearContent();
        Response.AddHeader("content-disposition", "attachment; filename=" + strFileName);
        // Set as Excel as the primary format
        Response.AddHeader("Content-Type", "application/Excel");
        Response.ContentType = "application/Excel";
        System.IO.StringWriter sw = new System.IO.StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        gridViewControl.RenderControl(htw);
        Response.Write(sw.ToString());

        //
        gridViewControl.Dispose();

        Response.End();
    }
开发者ID:daniela12,项目名称:gooptic,代码行数:23,代码来源:DownloadAttributes.ascx.cs

示例2: WriteToXls2

    /// <summary>
    /// 匯出轉單
    /// </summary>
    /// <param name="dtData"></param>
    /// <param name="strFileName"></param>
    public void WriteToXls2(DataTable dtData, string strFileName)
    {
        #region
        GridView gvExport = new GridView();
        try
        {
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=" +
                HttpUtility.UrlEncode(strFileName.Replace(".xls", ""), System.Text.UTF8Encoding.UTF8) + ".xls");
            Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");
            this.EnableViewState = false;

            System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
            gvExport.DataSource = dtData;
            gvExport.DataBind();
            gvExport.RenderControl(oHtmlTextWriter);
            Response.Write(@"<style>td{mso-number-format:\@}</style>");
            Response.Write(oStringWriter.ToString());
            Response.Flush();
            Response.End();
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", string.Format("alert('{0}');", ex.Message), true);
        }
        finally
        {
            gvExport.Dispose();
        }
        #endregion
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:39,代码来源:CRM171.aspx.cs

示例3: WriteToXls

    /// <summary>
    /// 輸出為EXCEL
    /// </summary>
    public void WriteToXls()
    {
        #region

        GridView gvExcel = new GridView();
        gvExcel.RowDataBound += new GridViewRowEventHandler(gvExcel_RowDataBound);
        try
        {
            ALOModel.MaintainStoreRank BCO = new ALOModel.MaintainStoreRank(ConnectionDB);
            DataTable dtExcel = null;
            string SessionIDName = string.Format("{0}_{1}_EXCELDATA", PAGE_DT_01, PageTimeStamp.Value);

            //匯出筆數上限
            Int32 iLimitedRowsCounts = 65535;

            if (BCO.CheckExcelOutCount(GetInputValues(), iLimitedRowsCounts))
            {

                dtExcel = BCO.QueryStorRankForExcel2_2(GetInputValues());

                if (dtExcel != null && dtExcel.Rows.Count > 0)
                {
                    Response.Clear();
                    Response.AddHeader("content-disposition", "attachment;filename=" +
                        HttpUtility.UrlEncode(txt_ExportFileName.Text.Trim().ToLower().Replace(".xls", ""), System.Text.UTF8Encoding.UTF8) + ".xls");
                    Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";
                    Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");
                    this.EnableViewState = false;

                    System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
                    System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);

                    gvExcel.AllowPaging = false;
                    gvExcel.AllowSorting = false;
                    gvExcel.DataSource = dtExcel;
                    gvExcel.DataBind();

                    gvExcel.RenderControl(oHtmlTextWriter);
                    Response.Write(oStringWriter.ToString());
                    Response.Flush();
                    Response.End();
                }
                else
                {
                    ResultMsgLabel.Text = "無匯出資料";
                }
            }
            else
            {
                throw new Exception("匯出筆數超過上限" + iLimitedRowsCounts.ToString() + "筆");
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally 
        {
            gvExcel.DataSource = null;
            gvExcel.Dispose();
        }

        #endregion
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:67,代码来源:ALO031.aspx.cs


注:本文中的GridView.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。