DataGrid ItemDataBound Performance Lag

  • Thread starter Thread starter _MC_
  • Start date Start date
M

_MC_

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.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
 
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
 
Hi,

acutally the loop hits in worst case 2 times.
However, not the reason of our problem. If we replace the SQL Request
with about 1000 Rows to an SQL Request with 1 Row, we have the same
effect. So the performance loose must have another reason. Any further
idea for detection?

Thanks

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_ said:
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.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
 
Back
Top