J
JohnE
I am able to export the datatable to excel. Below is the code that is being
used in the button click event by calling the below and passing in the
filename. But there are 2 columns in the datatable that are checkboxes. How
can I get those to show either true or false (checked/unchecked)? Example
code or links are good.
public void ExportGridToExcel(string fileName)
{
DataTable dataTable = new DataTable();
Response.ClearContent();
Response.AddHeader("content-disposition",
string.Format("attachment;filename={0}.xls", fileName));
Response.ContentType = "application/ms-excel";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
GridView gvExport = new GridView();
gvExport.DataSource = bindgrid();
gvExport.DataBind();
gvExport.RenderControl(htextw);
Response.Write(stw.ToString());
Response.End();
}
Thanks.
John
used in the button click event by calling the below and passing in the
filename. But there are 2 columns in the datatable that are checkboxes. How
can I get those to show either true or false (checked/unchecked)? Example
code or links are good.
public void ExportGridToExcel(string fileName)
{
DataTable dataTable = new DataTable();
Response.ClearContent();
Response.AddHeader("content-disposition",
string.Format("attachment;filename={0}.xls", fileName));
Response.ContentType = "application/ms-excel";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
GridView gvExport = new GridView();
gvExport.DataSource = bindgrid();
gvExport.DataBind();
gvExport.RenderControl(htextw);
Response.Write(stw.ToString());
Response.End();
}
Thanks.
John