Your loop executes 3 times per row of data, there's not much you can do here
to avoid the hit. You may consider removing the loop entirely and hard
coding items 1, 2 and 3. This will work if you don't plan on changing the
contents of the grid either now or in the future, other wise convert it to
static column and set its visibility flag to zero.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"_MC_" <mc@andariel.informatik.uni-erlangen.dewrote in message
news:11*********************@l75g2000hse.googlegro ups.com...
Hi,
recently I had to set some Columns in our Datagrid invisible. As we
use an dynamic Datagrid Binding, the only possible method is in
ItemDataBound Event:
protected void DataGrid1_ItemDataBound(object sender,
DataGridItemEventArgs e)
{
for(int i=1; i <= 3; i++)
e.Item.Cells[i].Visible =
false;
}
However, this part of code increases cpu load on server (for one table
about 20 sec 100% CPU Load on Athlon 64 3800+) .
Any ideas how we could handle this inacceptable performance lag?
Thanks a lot,
Stefan