How to hide columns in an ASP.NET GridView with auto-generated columns? -


gridview1.columns.count 0 sqldatasource1.databind();

but grid ok

i can do

for (int = 0; < gridview1.headerrow.cells.count;i++) 

i rename request headers here but

gridview1.columns[i].visible = false; 

i can't use because of gridview1.columns.count 0.

so how can hide them ?

try putting e.row.cells[0].visible = false; inside rowcreated event of grid.

protected void bla_rowcreated(object sender, gridviewroweventargs e) {     e.row.cells[0].visible = false; // hides first column } 

this way auto-hides whole column.

you don't have access generated columns through grid.columns[i] in gridview's databound event.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -