Background:SqlDataSource calls a stored procedure that creates a pivot table. Columns in the pivot are generated using dynamic SQL and user configured data, so I do not know the names of the columns at design time.WebDataGrid (2013.1) has 3 design time columns. AutoGenerateColumns equals true to build the unknown columns from the pivot table. There are two columns in the pivot (id columns) that are fixed and known at design time. I need to hide these two known pivot columns.I attempted to find the columns in the DataBound and InitializeRow events, but auto generated columns are not present in the columns collection. What is the point of the AutoGeneratedDataField? Shouldn't they be added to the column collection behind the scenes?How do I programmatically access any auto generated columns so I can hide columns of my choosing?
Hello Eric,
Thank you for posting in our forum.
By design the Autogenerated columns are not added to the Columns' collection of the grid.
However you could access them via the cells of the grid and set additional options for them, for example in the InitializeRow event:
protected void WebDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
{
e.Row.Items.FindItemByKey("ColumnKey").Column.Hidden = true;
}
Let me know if you have any additional questions or concerns regarding this.
Best Regards,
Maya Kirova
Developer Support Engineer II
Infragistics, Inc.
http://www.infragistics.com/support
So what is the reason for having the AutoGeneratedDataField class? According to your documentation:
"Represents a column or field that was generated from the DataSource of the WebDataGrid control."
However, I can find no way to access any object of that type from a WebDataGrid.