I been trying to export the stored procedure as an excel sheet, but the columns with datetime
type do not render in the resulted table
this is a simplified code sample
System.Web.UI.WebControls.DataGrid grid = new System.Web.UI.WebControls.DataGrid();
string fileName = "";
using (dbentities ctx = new dbentities())
{
grid.DataSource = ctx.GetRecord().Select(x => new { x.RequestID, x.CreatedDate }).ToList();
grid.DataBind();
fileName = "";
using (StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(fileName)))
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
grid.RenderControl(hw);
}
}
}