GridView自定義分頁---派生類(4a) .

来源:互联网 发布:sftp 端口号 编辑:程序博客网 时间:2024/05/01 08:45

 /// <summary>
        /// 轉頁
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void txt_TextChanged(object sender, EventArgs e)
        {
            int temp;
            if (int.TryParse(((TextBox)sender).Text, out temp))
            {
                CurrentPage = temp < 1 ? 1 : temp;
            }
            else
            {
                return;
            }
        }
        /// <summary>
        /// 匯出excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btn_Click(object sender, EventArgs e)
        {
            if (!SelectCommand.IsEmpty() && !OrderBy.IsEmpty())
            {
                this.DataBindForExcel();
            }
            else
            {
                if (ShowRecordCount)
                {
                    this.Controls[0].FindControl("trQueryResultExcel").Visible = false;
                }
                if (ShowExportExcelButton || TotalPage > 1)
                {
                    Table t = this.Controls[0] as Table;
                    t.Rows.RemoveAt(t.Rows.Count - 1);
                }
            }
            
            if (!ExportExcelHiddenColIndex.IsEmpty())
            {
                foreach (string ind in ExportExcelHiddenColIndex.Split(','))
                {
                    this.Columns[Convert.ToInt16(ind)].Visible = false;
                }
            }

            if (!ExportExcelClearControlIndex.IsEmpty())
            {
                RenderDataToText();
            }
            
            Coeno.ExcelUtility.ContorlToExcel.ToExcel(this);
        }
        /// <summary>
        /// 分頁button click事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void lbtn_Click(object sender, EventArgs e)
        {
            if (((LinkButton)sender).CommandArgument != "-1")
            {
                CurrentPage = Convert.ToInt32(((LinkButton)sender).CommandArgument);
            }

            SetDataSource(false);

            DataBind();
        }

原创粉丝点击