/// <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();
}