Hi Kostadin,
I tried: AlternateText='<%# Eval("Common_Flag") %>' on my Image declaration, but with no luck. Yes, I tried Bind as well as Eval.
Also, it seems that I'm getting an unexpected first row at the top of by exported file. I had to change my code to apply the header formatting to the 2nd row.
Here's my current OnInfrastructureExporting event handler:
protected void grdControls_InfrastructureExporting(object sender, GridInfrastructureExportingEventArgs e)
{
try
{
var colCount = e.ExportStructure.Tables[0].Columns.Count;
// Set the header style for all columns
var headerStyle = new ExportStyle();
headerStyle.ForeColor = Color.White;
headerStyle.BackColor = Color.Blue;
headerStyle.Font.Bold = true;
var booleanHeaderStyle = new ExportStyle();
booleanHeaderStyle.ForeColor = Color.White;
booleanHeaderStyle.BackColor = Color.Blue;
booleanHeaderStyle.Font.Bold = true;
booleanHeaderStyle.HorizontalAlign = HorizontalAlign.Center;
var booleanColumnStyle = new ExportStyle();
booleanColumnStyle.HorizontalAlign = HorizontalAlign.Center;
for (var i = 1; i <= colCount; i++)
{
e.ExportStructure.Tables[0].Cells[i, 2].Style = headerStyle;
e.ExportStructure.Tables[0].Columns[i].Width = 300; // Would like auto-width !!
}
// Place an "X" in cells assigned to a boolean data field if value is true
var rowCount = e.ExportStructure.Tables[0].Rows.Count;
for (var c = 1; c <= colCount; c++)
{
var booleanColumn = false;
for (var r = 2; r <= rowCount; r++)
{
var cellValue = e.ExportStructure.Tables[0].Cells[c, r].Value.ToString();
var cellText = e.ExportStructure.Tables[0].Cells[c, r].Text.ToString();
System.Diagnostics.Debug.WriteLine("Cell Value: " + cellValue + " cellText: " + cellText);
if (cellValue == "True" || cellValue == "False")
{
booleanColumn = true;
e.ExportStructure.Tables[0].Cells[c, r].Value = (cellValue == "True") ? "X" : "";
e.ExportStructure.Tables[0].Cells[c, r].Style = booleanColumnStyle;
}
}
if (booleanColumn)
{
e.ExportStructure.Tables[0].Cells[c, 1].Style = booleanHeaderStyle; // Also center the header
e.ExportStructure.Tables[0].Columns[c].Width = 100;
}
}
}
catch
(Exception ex)
{
HandleError(ex);
}
}
I've also attached a screenshot of an exported file.
As you can see the image appears (the checkmark).
What am I doing wrong?
Also, what happened to your documentation. It seems that it's taken a turn for the worse. For example how do I easily find the OnInfrastructureExporting event doc?
Thanks for any suggestions as to how to proceed.
Jim