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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -