By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,189 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,189 IT Pros & Developers. It's quick & easy.

ASP.NET data binding slow?

P: n/a
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...

// _viewDestinations is created once and stored in the ViewState

Private Sub dgWantList_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgWantList.ItemDataBound

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

e.Item.ItemType = ListItemType.AlternatingItem Then

Dim ctrl As Control = e.Item.FindControl("ddlDesignations")

If Not ctrl Is Nothing Then

Dim ddl As DropDownList = CType(ctrl, DropDownList)

ddl.DataSource = _viewDesignations

ddl.DataTextField = "the_text_field"

ddl.DataValueField = "the_value_field"

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:dropdownlists) 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
Share this Question
Share on Google+
8 Replies


P: n/a
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*****@newsgroups.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...

// _viewDestinations is created once and stored in the ViewState

Private Sub dgWantList_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs ) Handles
dgWantList.ItemDataBound

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

e.Item.ItemType = ListItemType.AlternatingItem Then

Dim ctrl As Control = e.Item.FindControl("ddlDesignations")

If Not ctrl Is Nothing Then

Dim ddl As DropDownList = CType(ctrl, DropDownList)

ddl.DataSource = _viewDesignations

ddl.DataTextField = "the_text_field"

ddl.DataValueField = "the_value_field"

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:dropdownlists) 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

P: n/a
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

P: n/a
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********@netscape.net> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.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

P: n/a
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.odetocode.com> wrote in message
news:a8********************************@4ax.com...
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*****@newsgroups.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...

// _viewDestinations is created once and stored in the ViewState

Private Sub dgWantList_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArg s) Handles
dgWantList.ItemDataBound

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

e.Item.ItemType = ListItemType.AlternatingItem Then

Dim ctrl As Control = e.Item.FindControl("ddlDesignations")

If Not ctrl Is Nothing Then

Dim ddl As DropDownList = CType(ctrl, DropDownList)

ddl.DataSource = _viewDesignations

ddl.DataTextField = "the_text_field"

ddl.DataValueField = "the_value_field"

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:dropdownlists) 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 #5

P: n/a
>> On Sat, 30 Apr 2005 12:05:40 -0400, "aualias"
<au*****@newsgroups.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
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?


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

P: n/a
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********@yahoo.se> wrote in message
news:%2*****************@tk2msftngp13.phx.gbl...
On Sat, 30 Apr 2005 12:05:40 -0400, "aualias"
<au*****@newsgroups.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
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?


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

P: n/a
"aualias" <au*****@newsgroups.nospam> wrote in message
news:OJ****************@TK2MSFTNGP10.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:Textbox1"];
dg is the name of the DataGrid. ctl2 specifies the second row. Textbox1 is
the name of the control.

Peter


Nov 19 '05 #8

P: n/a
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********@yahoo.se> wrote in message
news:uJ**************@TK2MSFTNGP15.phx.gbl...
"aualias" <au*****@newsgroups.nospam> wrote in message
news:OJ****************@TK2MSFTNGP10.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:Textbox1"];
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 discussion thread is closed

Replies have been disabled for this discussion.