473,768 Members | 6,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET data binding slow?

I am rewriting a web page that was previously done with ColdFusion. It has
a DataGrid and one column in the DataGrid is a dropdown list which is the
same for all rows. The ItemDataBound code looks like this...

// _viewDestinatio ns is created once and stored in the ViewState

Private Sub dgWantList_Item DataBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles
dgWantList.Item DataBound

If e.Item.ItemType = ListItemType.It em Or _

e.Item.ItemType = ListItemType.Al ternatingItem Then

Dim ctrl As Control = e.Item.FindCont rol("ddlDesigna tions")

If Not ctrl Is Nothing Then

Dim ddl As DropDownList = CType(ctrl, DropDownList)

ddl.DataSource = _viewDesignatio ns

ddl.DataTextFie ld = "the_text_field "

ddl.DataValueFi eld = "the_value_fiel d"

ddl.DataBind()

End If

End If

End Sub

The DataGrid loads very slowly, however the ColdFusion table loads quickly.
There may be other factors at work here - the two web pages are not on the
same server. I have no access to the ColdFusion code and do not know much
about ColdFusion.

The difference in load time is striking. However, the server that I am
developing on does not normally seem slow. There are 3 other dropdowns
(also asp:dropdownlis ts) in the DataGrid (in the table in the ColdFusion
page as well), but their values are hardcoded in the .aspx page.

My questions are...

1) Is there anything inherently wrong with the way I am creating the
DropDownList in the DataGrid?

2) Is it normal in this situation for an ASP.NET page to load slowly?

3) What can I do to speed up the page load?

Thanks.

David


Nov 19 '05 #1
8 4256
Hi aualias:

Does the performance improve to a reasonable level after the first
time you view the page? The first view can be notoriously slow because
of all the parsing, compiling, and JITing, and generaly "warm up" of
the application.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sat, 30 Apr 2005 12:05:40 -0400, "aualias"
<au*****@newsgr oups.nospam> wrote:
I am rewriting a web page that was previously done with ColdFusion. It has
a DataGrid and one column in the DataGrid is a dropdown list which is the
same for all rows. The ItemDataBound code looks like this...

// _viewDestinatio ns is created once and stored in the ViewState

Private Sub dgWantList_Item DataBound(ByVal sender As Object, ByVal e As
System.Web.UI. WebControls.Dat aGridItemEventA rgs) Handles
dgWantList.Ite mDataBound

If e.Item.ItemType = ListItemType.It em Or _

e.Item.ItemType = ListItemType.Al ternatingItem Then

Dim ctrl As Control = e.Item.FindCont rol("ddlDesigna tions")

If Not ctrl Is Nothing Then

Dim ddl As DropDownList = CType(ctrl, DropDownList)

ddl.DataSource = _viewDesignatio ns

ddl.DataTextFie ld = "the_text_field "

ddl.DataValueFi eld = "the_value_fiel d"

ddl.DataBind()

End If

End If

End Sub

The DataGrid loads very slowly, however the ColdFusion table loads quickly.
There may be other factors at work here - the two web pages are not on the
same server. I have no access to the ColdFusion code and do not know much
about ColdFusion.

The difference in load time is striking. However, the server that I am
developing on does not normally seem slow. There are 3 other dropdowns
(also asp:dropdownlis ts) in the DataGrid (in the table in the ColdFusion
page as well), but their values are hardcoded in the .aspx page.

My questions are...

1) Is there anything inherently wrong with the way I am creating the
DropDownList in the DataGrid?

2) Is it normal in this situation for an ASP.NET page to load slowly?

3) What can I do to speed up the page load?

Thanks.

David



Nov 19 '05 #2
I would guess it's the view state for the datagrid and all of the drop
down lists you have. Take a look at the html for the asp.net page and
see how large your viewstate is. I'll bet that it's very big and that
would account for the difference in load times.

If this is the case, the resolution would be to turn the view state off
for those controls if you can or selectively for certain elements in
your datagrid. I also remember seeing an article in ASP.NET Pro that
described how to keep the viewstate on the server rather than in the
page itself.

Note that both datagrids and dropdowns are notorious for causing "page
bloat" when their viewstate is enabled. Unfortunately, many of the
datagrid's events won't fire if you turn off the view state. In the
case of the listbox (and I think the dropdown), you must keep the
viewstate on in order to remember the selected value across postbacks.
Unfortunately, the entire list is also saved in the viewstate and you
have no choice about it.

Bill E.

Nov 19 '05 #3
The good news is that I viewed the page this morning and the load time was
MUCH quicker than the last time I looked at it, so part of the problem is
the development server.

On the other hand, the load time was not great. As you suspected, the
ViewState is enormous, but I cannot turn it off for the DataGrid because I
will lose the user's selections.

I shall look for information on leaving the view state on the server. This
is not a high volume site, so I do not think that it would be a problem.
Perhaps I could store the DataGrid in the session object.

Thanks for your help.

David

<bi********@net scape.net> wrote in message
news:11******** *************@l 41g2000cwc.goog legroups.com...
I would guess it's the view state for the datagrid and all of the drop
down lists you have. Take a look at the html for the asp.net page and
see how large your viewstate is. I'll bet that it's very big and that
would account for the difference in load times.

If this is the case, the resolution would be to turn the view state off
for those controls if you can or selectively for certain elements in
your datagrid. I also remember seeing an article in ASP.NET Pro that
described how to keep the viewstate on the server rather than in the
page itself.

Note that both datagrids and dropdowns are notorious for causing "page
bloat" when their viewstate is enabled. Unfortunately, many of the
datagrid's events won't fire if you turn off the view state. In the
case of the listbox (and I think the dropdown), you must keep the
viewstate on in order to remember the selected value across postbacks.
Unfortunately, the entire list is also saved in the viewstate and you
have no choice about it.

Bill E.

Nov 19 '05 #4
Scott,

The load time is slow even after the first view. I think that Bill's
thoughts on the view state being huge is the main part of the problem.

Thanks.

David

"Scott Allen" <sc***@nospam.o detocode.com> wrote in message
news:a8******** *************** *********@4ax.c om...
Hi aualias:

Does the performance improve to a reasonable level after the first
time you view the page? The first view can be notoriously slow because
of all the parsing, compiling, and JITing, and generaly "warm up" of
the application.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sat, 30 Apr 2005 12:05:40 -0400, "aualias"
<au*****@newsgr oups.nospam> wrote:
I am rewriting a web page that was previously done with ColdFusion. It
has
a DataGrid and one column in the DataGrid is a dropdown list which is the
same for all rows. The ItemDataBound code looks like this...

// _viewDestinatio ns is created once and stored in the ViewState

Private Sub dgWantList_Item DataBound(ByVal sender As Object, ByVal e As
System.Web.UI .WebControls.Da taGridItemEvent Args) Handles
dgWantList.It emDataBound

If e.Item.ItemType = ListItemType.It em Or _

e.Item.ItemType = ListItemType.Al ternatingItem Then

Dim ctrl As Control = e.Item.FindCont rol("ddlDesigna tions")

If Not ctrl Is Nothing Then

Dim ddl As DropDownList = CType(ctrl, DropDownList)

ddl.DataSource = _viewDesignatio ns

ddl.DataTextFie ld = "the_text_field "

ddl.DataValueFi eld = "the_value_fiel d"

ddl.DataBind()

End If

End If

End Sub

The DataGrid loads very slowly, however the ColdFusion table loads
quickly.
There may be other factors at work here - the two web pages are not on the
same server. I have no access to the ColdFusion code and do not know much
about ColdFusion.

The difference in load time is striking. However, the server that I am
developing on does not normally seem slow. There are 3 other dropdowns
(also asp:dropdownlis ts) in the DataGrid (in the table in the ColdFusion
page as well), but their values are hardcoded in the .aspx page.

My questions are...

1) Is there anything inherently wrong with the way I am creating the
DropDownLis t in the DataGrid?

2) Is it normal in this situation for an ASP.NET page to load slowly?

3) What can I do to speed up the page load?

Thanks.

David


Nov 19 '05 #5
>> On Sat, 30 Apr 2005 12:05:40 -0400, "aualias"
<au*****@newsgr oups.nospam> wrote:
I am rewriting a web page that was previously done with ColdFusion. It
has
a DataGrid and one column in the DataGrid is a dropdown list which is the
same for all rows. The ItemDataBound code looks like this...
<snip>
My questions are...

1) Is there anything inherently wrong with the way I am creating the
DropDownLi st in the DataGrid?

2) Is it normal in this situation for an ASP.NET page to load slowly?

3) What can I do to speed up the page load?


Check this page for ideas on how to reduce the viewstate:
http://www.codeproject.com/aspnet/DataGridViewState.asp

The basic idea is to turn off the viewstate on all rows. It works great if
you only neeed an id for the row that the user selected. If the user is also
able to edit the contents, perhaps it's possible to turn off the viewstate
for all rows except the row being edited.

Peter
Nov 19 '05 #6
Peter,

This is an interesting article. I'm not sure that I can use it for this
problem, but it is a good thing to know about.

This datagrid has a checkbox column and a series of dropdowns that the user
can edit. If they check several columns, then the data goes into the
database, so the data from each checked row has to be saved.

Realistically, I think that the old design of this page is not great. If I
cannot get the page to display reasonably quickly, then I will change the
design to something quicker and probably more intuitive for the user.

Thanks.

David
"Peter Laan" <pl********@yah oo.se> wrote in message
news:%2******** *********@tk2ms ftngp13.phx.gbl ...
On Sat, 30 Apr 2005 12:05:40 -0400, "aualias"
<au*****@newsgr oups.nospam> wrote:

I am rewriting a web page that was previously done with ColdFusion. It
has
a DataGrid and one column in the DataGrid is a dropdown list which is
the
same for all rows. The ItemDataBound code looks like this...
<snip>
My questions are...

1) Is there anything inherently wrong with the way I am creating the
DropDownLis t in the DataGrid?

2) Is it normal in this situation for an ASP.NET page to load
slowly?

3) What can I do to speed up the page load?


Check this page for ideas on how to reduce the viewstate:
http://www.codeproject.com/aspnet/DataGridViewState.asp

The basic idea is to turn off the viewstate on all rows. It works great if
you only neeed an id for the row that the user selected. If the user is
also able to edit the contents, perhaps it's possible to turn off the
viewstate for all rows except the row being edited.

Peter

Nov 19 '05 #7
"aualias" <au*****@newsgr oups.nospam> wrote in message
news:OJ******** ********@TK2MSF TNGP10.phx.gbl. ..
Peter,

This is an interesting article. I'm not sure that I can use it for this
problem, but it is a good thing to know about.

This datagrid has a checkbox column and a series of dropdowns that the
user can edit. If they check several columns, then the data goes into the
database, so the data from each checked row has to be saved.

Realistically, I think that the old design of this page is not great. If
I cannot get the page to display reasonably quickly, then I will change
the design to something quicker and probably more intuitive for the user.


I think you can do even this without viewstate. All checkbox and dropdown
values will be sent to the sever. Just check the Request like this (for a
textbox):

string test = Request["dg:_ctl2:Textb ox1"];
dg is the name of the DataGrid. ctl2 specifies the second row. Textbox1 is
the name of the control.

Peter


Nov 19 '05 #8
Peter,

I won't be able to get to it for a while, but this sounds very interesting.
If I can remove the DataGrid from the ViewState and still get at the
dropdown values, the page may load acceptably.

Thanks.

David

"Peter Laan" <pl********@yah oo.se> wrote in message
news:uJ******** ******@TK2MSFTN GP15.phx.gbl...
"aualias" <au*****@newsgr oups.nospam> wrote in message
news:OJ******** ********@TK2MSF TNGP10.phx.gbl. ..
Peter,

This is an interesting article. I'm not sure that I can use it for this
problem, but it is a good thing to know about.

This datagrid has a checkbox column and a series of dropdowns that the
user can edit. If they check several columns, then the data goes into
the database, so the data from each checked row has to be saved.

Realistically, I think that the old design of this page is not great. If
I cannot get the page to display reasonably quickly, then I will change
the design to something quicker and probably more intuitive for the user.


I think you can do even this without viewstate. All checkbox and dropdown
values will be sent to the sever. Just check the Request like this (for a
textbox):

string test = Request["dg:_ctl2:Textb ox1"];
dg is the name of the DataGrid. ctl2 specifies the second row. Textbox1 is
the name of the control.

Peter

Nov 19 '05 #9

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

Similar topics

2
2045
by: kk | last post by:
Have 2 problems, any help is appreciated. Tab with Grids -------------- BL - fetching data from DB ( 5 secs - 10 rows) Grid Laod - 20 secs Grid Paint on tab change - 20 secs Problem: The data fetch only takes 5 secs, why does paint and load take 40 secs in total.
0
2348
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a visual representation of data. Two types of data binding are available for Windows Forms: Simple Data Binding and Complex Data Binding. Simple data binding allows you to bind one data element to a control. In many situations you want to display...
16
3037
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
5
2447
by: amanatio | last post by:
I have a huge form with many data bound controls on it and 34 tables in database (and of course 34 data adapters and 34 datasets). The form is extremely slow to design (huge delay when I go to code from design mode or vice versa) and to show. I didn't design the form but I WILL redisgn it from scratch. What would you propose me to do? The form now haw a tab control with 7 tabs and about 600 text boxes that are bounded to 34 datasets... ...
3
1492
by: Agnes | last post by:
I got a tables which got 10,000 records. user will input the invoice no as key. my strConnection = "select * from invoice_Table where invno ='" & (Me.txtInvoiceNo.Text) &"' " in my form, there are over 20 textbox. If i use databinding to bind each textbox. will it become slow ??? if i move the position, will it slow ?? Thanks
14
14657
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control so I get the ObjectDataSource. No problem ..... ObjectDataSource src = .... //is ok i have it
7
10068
by: John J. Hughes II | last post by:
I have a DataGridView with a TextBoxColumn. I setting the data source to a List<stringvalue in a static class. The list is filled from a background thread. So far all is fine and it works great, at least on my system. The reason I am doing this is some customers are pulling from VPN connections which are slow. This allows the list of rows in the data grid to appear a little quicker while the list which are not used as soon load in...
9
4024
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. DatasetInit.Tables.Add(tblSliceInfo)
10
5849
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi, Problem: How can I databind (or put) a SqlServer query's row return of 115,000 items into a ComboBox quickly? Not much longer than a matter of seconds, that is... Scenario: I am rebuilding my company's Access 97 VBA database app. It pulls 115,000 items (of account names) from SqlServer and the data is bound to a single Access 97 ComboBox control. My C# version needs to work exactly like this one. Our executive employees want...
0
9407
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10176
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10018
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9964
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9845
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8840
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7387
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2808
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.