Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Webpage is working unusually slow

Posted on 2012-03-13
7
Medium Priority
?
327 Views
Last Modified: 2012-04-09
I am working on a webpage in my web application. It is a fairly simple application with a datagrid which is populated from an Excel file and also from the database. The number of rows in the datagrid is in hundreds. I understand if it takes time to upload the rows. But after the datagrid is loaded, even a button click event is taking like 2 minutes. The button click event is just making a panel message box visible. How can I figure out what's taking so long?
0
Comment
Question by:Angel02
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 36

Assisted Solution

by:Miguel Oz
Miguel Oz earned 800 total points
ID: 37717345
If you are using VS2010, you can use the performance profiler:
http://msdn.microsoft.com/en-us/library/ms182372.aspx

Depending on your business rules, you should aim to interact with Excel as little as possible. For example loading Excel information into Session (if you do not need to interact/save results back)
Can you provide some sample code on how you are loading the datagrid?
0
 
LVL 9

Expert Comment

by:abhinayp86
ID: 37717428
in the datagrid, turnoff viewstate and c if the page is any faster.
Also make sure that u are binding the grid in "If not Page.IsPostBack" in page load
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37717696
Show us some code.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:Angel02
ID: 37718429
I have attached code for my function BindGrid() which loads the Datagrid. I use a stored procedure to populate the datagrid.
I also have a ItemDataBound Event where I am assigning different colors to the rows depending on a column value. I have used similar code for ItemDataBound event in other webpages but they were not not slowed down.

- After the datagrid is loaded, any onclick event is taking for ever to complete. It looks like the whole page is refreshing, although the onclick event which just makes an asp:Panel visible is not supposed to refresh the page.
It is taking time to reload the page even if a button click just calls
Response.Write("<Script Language='JavaScript'>alert('Are you sure you want to continue?');</Script>")

- I made enableviewstate="false". The on click events worked super fast as expected. But after a button or checkbox click, the datagrid disappeared.

- I am not binding the datagrid in the pageload(). I have a "browse" button on my webpage which selects an Excel file and when I click "Upload", then the datagrid is loaded.
BindGrid.txt
ItemDataBound.txt
0
 
LVL 16

Expert Comment

by:Rose Babu
ID: 37718633
are you calling BindGrid() function for some other process in same page?

check the BindGrid occurrences.
0
 
LVL 9

Accepted Solution

by:
abhinayp86 earned 1200 total points
ID: 37722618
I have a feeling that your BindGrid() is being called too many times during a normal postback.

If thats not the case and ur page is still slow, turnoff the viewstate for the grid, and use session to save and retrieve data. (Code below)

 
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
	 If m_BrowseClick = 1 Then
            If Session("excelSP_data") Is Nothing Then 'Only true when session timesout
                BindGrid()
            Else
                MyDataGrid.DataSource = Session("excelSP_data")
                MyDataGrid.DataBind()
            End If
        End If
  End Sub

 Private Property m_BrowseClick () As Integer
        Get
            Try
                Return ViewState("browse_click")
            Catch ex As Exception
                Return 0
            End Try

        End Get
        Set(ByVal value As Integer)
            ViewState("browse_click") = value
        End Set
    End Property

Sub BindGrid()
        Dim mydataset As DataSet = New DataSet
        MyConnection = New SqlConnection(Conn)
        Dim MyAdapter As SqlDataAdapter
        Dim MyCommand As SqlCommand
        MyCommand = New SqlCommand("ExcelSP", MyConnection)
        MyCommand.CommandType = CommandType.StoredProcedure
        MyCommand.Parameters.Add("@ID", SqlDbType.Int).Value = CInt(Session("ID"))
        MyAdapter = New SqlDataAdapter(MyCommand)
        Try
            MyAdapter.Fill(mydataset, "ExcelList")
            
        Catch ex As Exception
            Throw (ex)
        End Try
        If mydataset.Tables(0).Rows.Count >= 1 Then
            m_BrowseClick = 1
            session("excelSP_data") = mydataset
            MyDataGrid.DataSource = mydataset
            MyDataGrid.DataBind()
        else
          m_BrowseClick = 0
        End If
        MyCommand.Dispose()
        MyAdapter.Dispose()
        mydataset.Dispose()
        MyConnection.Close()
    End Sub

Open in new window

0
 

Author Comment

by:Angel02
ID: 37722671
I traced for bindgrid occurrences. It is being called only once. The page is being loaded after every click but bindgrid() is not in page load.
I'll try the code to use the session and see.
0

Featured Post

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question