Saturday, September 8, 2007

GridVIew make Column Invisible

u mostly make a column invisible in GridView so that u can use it internally in ur code for other purpose like this:

but when u access it in C# the Text of this cell will be empty.
The Text can be accessed only when the Cell is Visible

To get around this problem make the cell as Visible = false in Row_Created event in C#
Even this does not work I get index out of bound exception
The way out is the following code:
listtaskGridView.DataSource = ListTaskDS;
listtaskGridView.DataBind();
listtaskGridView.Columns[0].Visible = false;
listtaskGridView.Columns[7].Visible = false; listtaskGridView.Columns[8].Visible = false;

No comments: