GridView自定義分頁---派生類(3)

 /// <summary>
        /// 加入 查詢筆數顯示
        /// </summary>
        /// <param name="fields"></param>
        private void CreateResultRow(DataControlField[] fields)
        {
            GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal);

            row.ID = "trQueryResultExcel";

            row.CssClass = "QueryResultCSS";

            row.Cells.Clear();

            TableHeaderCell cell = new TableHeaderCell();

            cell.HorizontalAlign = HorizontalAlign.Left;

            row.Cells.Add(cell);

            cell.Style.Add("border", "0px");
            cell.Style.Add("padding", "0 0 3px 0");

            cell.ColumnSpan = fields.Length;

            Literal liter = new Literal();

            liter.Text = String.Format("<font color='#2A58A4' ><b>查詢結果:共 {0} 筆資料 </b></font>", TotalCount);

            cell.Controls.Add(liter);

            Table t = this.Controls[0] as Table;

            t.Rows.AddAt(0, row);
        }
        /// <summary>
        /// 創建匯出excel button
        /// </summary>
        /// <param name="row"></param>
        /// <param name="colspan"></param>
        private void AddExportExcelButton(TableHeaderCell cell)
        {
            Button btn = new Button();

            btn.ID = "btnExporExcel"+this.ID;

            btn.Text = "匯出Excel檔";

            btn.Width = Unit.Parse("80px");

            btn.CssClass = "btn_mouseout";

            btn.CausesValidation = false;

            btn.Click += new EventHandler(btn_Click);

            HtmlGenericControl div1 = new HtmlGenericControl("div");

            div1.Style.Add("float", "right");

            div1.Controls.Add(btn);

            cell.Controls.Add(div1);
           
            if (Page.Master != null && Page.Master.FindControl("ToolkitScriptManager1") != null)
            {
                ((ScriptManager)Page.Master.FindControl("ToolkitScriptManager1")).RegisterPostBackControl(btn);
            }
            else if (Page.FindControl("ToolkitScriptManager1") != null)
            {
                ((ScriptManager)Page.FindControl("ToolkitScriptManager1")).RegisterPostBackControl(btn);
            }
        }

        /// <summary>
        /// 取得查無資料時要顯示的欄位
        /// </summary>
        /// <returns>查無資料時要顯示的欄位</returns>
        private DataControlField[] GetEmptyFields()
        {
            List<DataControlField> list = new List<DataControlField>(this.Columns.Count);
            
            foreach (DataControlField field in this.Columns)
            {
                if (field.Visible)
                {
                    list.Add(field);
                }
            }
            
            return list.ToArray();
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值