Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET data binding slow?

Reply
Thread Tools

ASP.NET data binding slow?

 
 
aualias
Guest
Posts: n/a
 
      04-30-2005
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








 
Reply With Quote
 
 
 
 
Scott Allen
Guest
Posts: n/a
 
      04-30-2005
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"
<> 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
>
>
>
>
>
>
>


 
Reply With Quote
 
 
 
 
billmiami2@netscape.net
Guest
Posts: n/a
 
      04-30-2005
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.

 
Reply With Quote
 
aualias
Guest
Posts: n/a
 
      05-02-2005
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



<> wrote in message
news: 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.
>



 
Reply With Quote
 
aualias
Guest
Posts: n/a
 
      05-02-2005
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" <> wrote in message
news:...
> 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"
> <> 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
>>
>>
>>
>>
>>
>>
>>

>



 
Reply With Quote
 
Peter Laan
Guest
Posts: n/a
 
      05-03-2005
>> On Sat, 30 Apr 2005 12:05:40 -0400, "aualias"
>> <> 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


 
Reply With Quote
 
aualias
Guest
Posts: n/a
 
      05-03-2005
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" <> wrote in message
news:%23vYaFK%...
>>> On Sat, 30 Apr 2005 12:05:40 -0400, "aualias"
>>> <> 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
>
>



 
Reply With Quote
 
Peter Laan
Guest
Posts: n/a
 
      05-04-2005
"aualias" <> wrote in message
news:OJVtj6%...
> 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




 
Reply With Quote
 
aualias
Guest
Posts: n/a
 
      05-04-2005
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" <> wrote in message
news:...
> "aualias" <> wrote in message
> news:OJVtj6%...
>> 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
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView binding - how to stop initial binding Amit ASP .Net 6 10-24-2006 08:06 AM
pywin32 COM sort in Excel (late binding fails, early binding works) (+py2exe) kogrover@gmail.com Python 2 10-20-2006 04:08 PM
Complex data binding question, binding child objects of a custom collection. JcFx ASP .Net Datagrid Control 0 06-01-2005 04:01 PM
Data Binding - using inline code vs. functions vs. straight binding Jordan ASP .Net 2 02-10-2004 08:32 PM
value binding and function binding Vivek Nallur Ruby 0 09-25-2003 02:52 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57