I have multiple gridviews on one page some with textboxes, others with labels/text. The labels are calculated from other textbox values using javaScript and are placed in the gridview that way. The problem is, the labels are not exporting to excel. I'm wondering if it's because they are created dynamically with javaScript. However, I need these values to export as well. Any help is appreciated!
I've tried data binding again on the export click but no go.
protected void export_Click(object sender, EventArgs e)
{
Response.ClearContent();
Response.AppendHeader("content-disposition", "attachment; filename=AvailableFundsCosts.xls");
Response.ContentType = "application/excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gridSFS.RenderControl(htw);
gridTLS.RenderControl(htw);
gridPCOTotals.RenderControl(htw);
gridPTA.RenderControl(htw);
gridPC.RenderControl(htw);
gridTL.RenderControl(htw);
gridFinal.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
Here is example of javascript using the grid to place an label value in another part of the gridview:
function calculateGTASemestersOtherActivity()
{
var GTASemestersOtherActivity = parseFloat(document.getElementById("cphMain_gridPTA_iTxtAmount_4").value);
var GTASemesterStipend = parseFloat(document.getElementById("cphMain_gridTLS_iTxtAmount_5").value);
if(isNaN(GTASemestersOtherActivity))
{GTASemestersOtherActivity = 0.00;}
if(isNaN(GTASemesterStipend))
{GTASemesterStipend = 0.00;}
var OtherActivityCost = parseFloat(GTASemestersOtherActivity * GTASemesterStipend);
var cell = document.getElementById("cphMain_gridPC").rows[8].cells;
cell[1].innerHTML = OtherActivityCost.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
}
I need the label values to export excel as well as the textboxes.