Example #1
0
 protected void ExportButtonWaiting_Click(object sender, EventArgs e)
 {
     if ((GridViewWaitingList.Rows.Count == 0) || (GridViewWaitingListIncharge.Rows.Count == 0))
     {
         LabelWaitingExport.Visible = true;
         LabelWaitingExport.Text    = "No data to export!";
     }
     else
     {
         Response.ClearContent();
         Response.Buffer = true;
         Response.AddHeader("content-disposition", string.Format("attachment;filename={0}", "WaitingList.xls"));
         Response.ContentType = "application/ms-excel";
         StringWriter   sw = new StringWriter();
         HtmlTextWriter hw = new HtmlTextWriter(sw);
         GridViewWaitingListExport.AllowPaging = false;
         GridViewWaitingListExport.HeaderRow.Style.Add("background-color", "#ffffff");
         for (int i = 0; i < GridViewWaitingListExport.HeaderRow.Cells.Count; i++)
         {
             GridViewWaitingListExport.HeaderRow.Cells[i].Style.Add("background-color", "#df5015");
         }
         GridViewWaitingListExport.RenderControl(hw);
         Response.Write(sw.ToString());
         Response.End();
     }
 }