473,396 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DataGrid ItemDataBound Performance Lag

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

Mar 20 '07 #1
2 1884
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

Mar 22 '07 #2
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
Alvin Bruney [MVP] schrieb:
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
Mar 22 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
3
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
7
by: Scott Schluer | last post by:
Hi All, I have a functioning datagrid on "Page 1" that displays order information for a single order (this is for an e-commerce site). It's actually a combination of a couple datagrids to...
2
by: Daniel Walzenbach | last post by:
Hi, I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to...
12
by: Daniel Walzenbach | last post by:
Hi, I want to display a Label in a DataGrid according to some condition. I therefore check whether the condition is true in the ItemDateBound EventHandler of the DataGrid. Unfortunately the...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
1
by: needin4mation | last post by:
Hi, I have a datalist. In this datalist I have a datagrid. The datalist is the master. The datagrid is the detail. It works fine. I populate the datagrid inside of the datalist using the...
2
by: johnnyG | last post by:
I've tried this approach but it's not quite what I want: Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _ ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _ Handles...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.