Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
100
Does the AutoGeneratedDataField actually serve a purpose with the WebDataGrid?
posted

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?

Parents
No Data
Reply
  • 29417
    Offline posted

    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

     

Children