"graphicsxp" <sa*************@googlemail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Can you help ?
I certainly can! What you've stumbled on is a new feature of the GridView
object, which differs from the DataGrid object in v1.x
Basically, Microsoft have decided that hidden columns in DataGrids were
almost always used to store primary keys of records, and that maintaining
them in ViewState represented a security risk. Therefore, in the GridView
object introduced in v2, hidden columns have been removed from ViewState by
default, which is why the columns themselves are still there (otherwise you
couldn't reference them in the CodeFile), but their values are blank.
Fortunately, there is an easy workaround. Simply set the column(s) to
Visible immediately before invoking the GridView's DataBind() method, and
then hide them again immediately after. E.g.
MyGridView.DataSource = <some sort of DataSet, SqlDataReader, whatever>
MyGridView.Columns[0].Visible = true;
MyGridView.DataBind();
MyGridView.Columns[0].Visible = false;