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
375
WebDataGrid Columns collection is empty when autogeneratecoumns=true
posted

I'm trying to walk through every column in a WebDataGrid to save column visible index information, but when the WebDataGrid has AutoGeneratecolumns=true following code does not work because columns collection is empty.

foreach (GridField col in WebDataGrid.Columns)
{
    sbColumnIndex.AppendFormat("{0}:{1};", col.Key, col.VisibleIndex);
}   

Is this a bug? or how can I get the columns collection on grids with autogeneratedcolumn = true.

thanks

OscarG

  • 14049
    Suggested Answer
    Offline posted

    Hello Oscar,

    Just like in the GridView, the Columns collection contains only the column objects that were added by hand in either aspx or in the code behind.
    The autogenerated columns are for the display purpose only, they cannot be accessed or modified.