Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

Webpage is working unusually slow

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
Angel02
Asked:
Angel02
2 Solutions
 
Miguel OzSoftware EngineerCommented:
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
 
abhinayp86Commented:
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
 
CodeCruiserCommented:
Show us some code.
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
Angel02Author Commented:
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
 
Rose BabuSenior Team ManagerCommented:
are you calling BindGrid() function for some other process in same page?

check the BindGrid occurrences.
0
 
abhinayp86Commented:
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
 
Angel02Author Commented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now