DataGrid ItemDataBound Performance Lag

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
 
A

Alvin Bruney [MVP]

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
 
M

_MC_

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top