I found the exact issue, it has to do with a dynamically created grid with invisible columns. I created two grids, one defined in the markup, and one created dynamically. The static grid is fine when exporting, but the dynamic one misses a column. I used 4 columns with 2 of them inside a column group. When I set one of the columns to visible = false on the dynamic grid it messes up the export. In the static grid the export is fine. The attached screenshot shows the different exports. Is there any way to submit this as a bug, or a workaround for the issue?
protected
void
Page_Load(
object
sender, EventArgs e)
{
rgDynamic.AutoGenerateColumns =
false
;
if
(!Page.IsPostBack)
{
var colPre1 =
new
GridBoundColumn();
rgDynamic.MasterTableView.Columns.Add(colPre1);
colPre1.UniqueName =
"colPre1"
;
colPre1.HeaderText =
"Col Pre 1"
;
//Invisible Column
var colPre2 =
new
GridBoundColumn();
rgDynamic.MasterTableView.Columns.Add(colPre2);
colPre2.Visible =
false
;
colPre2.UniqueName =
"colPre2"
;
colPre2.HeaderText =
"Col Pre 2"
;
var colGroup1 =
new
GridColumnGroup();
rgDynamic.MasterTableView.ColumnGroups.Add(colGroup1);
colGroup1.Name =
"cg1"
;
colGroup1.HeaderText =
"Col Group 1"
;
var col1 =
new
GridBoundColumn();
rgDynamic.MasterTableView.Columns.Add(col1);
col1.UniqueName =
"col1"
;
col1.HeaderText =
"Col 1"
;
col1.ColumnGroupName =
"cg1"
;
var col2 =
new
GridBoundColumn();
rgDynamic.MasterTableView.Columns.Add(col2);
col2.UniqueName =
"col2"
;
col2.HeaderText =
"Col 2"
;
col2.ColumnGroupName =
"cg1"
;
}
rgDynamic.DataSource = String.Empty;
rgDynamic.DataBind();
rgStatic.DataSource = String.Empty;
rgStatic.DataBind();
}