Results 1 to 12 of 12

Thread: Show GridViews at Initial PageLoad

  1. #1

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Question Show GridViews at Initial PageLoad

    I have an application where I currently are calling stored procedures, reading tables and filling GridView at PageLoad (If Not IsPostBack Then ...). The process takes some time and leaves the client waiting for this process to be completed even before showing the page.

    Now, is there a way where I can open the page, show a hour glass (or similar) and then automatically fill the gridviews? Is this where I should use threading (or backgroundworker) ?

    Thank you.
    Last edited by snufse; Jun 15th, 2010 at 02:20 PM.

  2. #2
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Show GridViews at Initial PageLoad

    Quote Originally Posted by snufse View Post
    I have an application where I currently are calling stored procedures, reading tables and filling GridView at PageLoad (If Not IsPostBack Then ...). The process takes some time and leaves the client waiting for this process to be completed even before showing the page.

    Now, is there a way where I can open the page, show a hour glass (or similar) and then automatically fill the gridviews? Is this where I should use threading (or backgroundworker) ?

    Thank you.
    Never done it, but I would imagine you could probably load the gridview in a separate event like LoadComplete.
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  3. #3
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: Show GridViews at Initial PageLoad

    hey,
    try this link
    http://msdn.microsoft.com/en-us/library/ms186734.aspx

    you can use it to speed your Query
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  4. #4

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Question Re: Show GridViews at Initial PageLoad

    I will try avrail's suggestion. In the meantime I been playing with this code:


    Code:
    If Not IsPostBack Then...
    
     Dim myThread As Thread = New Thread(AddressOf myLoad)
                myThread.Priority = ThreadPriority.Lowest
                myThread.Start()
    ........
    Code:
    Protected Sub myLoad()
    
            Get_Petroleum_Disbursement()
            Get_Petroleum_Receipt()
          
    End Sub

    Now it loads the page while the thread is running, not sure how to "force" post back or how to redisplay page with data (response.redirect ?). Not even sure if this is a good approach?

    Thank you.
    Last edited by snufse; Jun 15th, 2010 at 03:52 PM.

  5. #5
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: Show GridViews at Initial PageLoad

    hey,
    i believe that the link above will make the gridview more speeder than what you think,
    and good luck
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  6. #6
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: Show GridViews at Initial PageLoad

    I don't think threading will work for a disconnected client (browser/server) the same way you can use it for a connected client (win form) to run a process in the background while the main form remains responsive to the client.

    There are several option I can think of. 1 Avrails suggestion of improving overall performance of the entire page by optimizing queries, viewstate etc.... 2. Return part of the page using response.flush and the rest will follow when it's complete http://msdn.microsoft.com/en-us/libr...nse.flush.aspx. 3. Seperate your lengthy gridview process to use an ajax call to load it or maybe even load it in an iFrame.

    The cleanest approach is to optomize your page so it loads fast. If that's not going to happen then start complicating it

  7. #7
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: Show GridViews at Initial PageLoad

    i will use the option number 2 as a plus
    good link out there
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show GridViews at Initial PageLoad

    snufse,

    Have you tried timing the query by itself directly against the database? How long does it take?

    Gary

  9. #9
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: Show GridViews at Initial PageLoad

    Quote Originally Posted by gep13 View Post
    snufse,

    Have you tried timing the query by itself directly against the database? How long does it take?

    Gary
    hey snufse,
    you may want to add Index on your tables or your views also
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  10. #10

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Re: Show GridViews at Initial PageLoad

    Hi everybody that have shown interest to help me out!

    This application is internal and the requirements are to show several grid views when opening the page. In actuality there are 5 grid views being displayed and data comes from different data bases (in total I am querying 10 data bases, some being Advantage data bases, some being db2/400 data bases and some on sequel server). I think it will be hard to index as they all have slightly different sql syntax.

    The response time is about 50-60 seconds and I hate for the user to sit and wait for the page to display pending completion of data base reads. I rather display an empty page with a message like "Loading data, please wait...." and then kick off my stored procedures.

    It sounds like this is a complicated achievement and maybe I need to find another way around this...

    Thank you.

  11. #11
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show GridViews at Initial PageLoad

    snufse,

    The 50-60 seconds, is the total time taken for the page to load, right?

    If you run the query that you are using on the GridView's directly against the database, how long do they take? Is there one that is significantly longer than others?

    Gary

  12. #12

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Question Re: Show GridViews at Initial PageLoad

    Yes, there is one stored procedure that stands out and taking long time. I have included the sql script (not sure if I am allowed to do that in this forum). This script repeats itsself 8 times and as we have eight different sites (Advantage data bases)

    Code:
    create table	#PlantTable
    	         		   (  
                           plant_id char(10) default ' ',
                           plant_name char(20) default Null,
    			           shift_date varchar(25) default Null,
    			           outside_qty decimal(15,2) default Null,
    			           intercompany_qty decimal(15,2) default Null 
                    		)
    
    IF @PlantName = '*All' or @PlantName = 'RGDB'
    begin
    
    Insert Into #PlantTable(shift_date, intercompany_qty, outside_qty)
    SELECT *
      FROM OPENQUERY(ADS_RGDB_SERVER, 'SELECT CONVERT(MAX(shift_started), SQL_VARCHAR) as shift_date,
                                              SUM(CASE WHEN customer = ''35''
                                                            THEN net
                                                       ELSE 0
                                                  END) AS intercompany_qty,
                                              SUM(CASE WHEN customer <> ''35''
                                                            THEN net
                                                       ELSE 0
                                                  END) AS outside_qty
                                         FROM salestkt
                                         WHERE (void is null or void = false) and
                                               incoming_material = false and 
                                               shift_started = (SELECT MAX(STK.shift_started) as shift
                                                                 FROM salestkt AS STK
                                                                  WHERE NOT EXISTS(SELECT *
                                                                                    FROM SHFTDATE AS SD
                                                                                      WHERE SD.shift_started is not Null and
                                                                                            SD.shift_started = STK.shift_started))')
    
                                   
    update #PlantTable set plant_id = 'RGDB', plant_name = 'Debary' where plant_id = ' '
    end


    Also tried this:

    Code:
    If Not IsPostBack Then
                
                Dim myThread As Thread = New Thread(AddressOf myLoad)
                myThread.Priority = ThreadPriority.Lowest
                myThread.Start()
    Code:
    Protected Sub myLoad()
    
            Response.Buffer = True
            Get_Petroleum_Disbursement()
            Get_Petroleum_Receipt()
            Response.Flush()
    Error:
    Response is not available in this context.


    Is there a way to "simulate" a button click like:

    Code:
    <div style="visibility:hidden"><asp:Button ID="Button11" runat="server" OnClick="Button1_Click" UseSubmitBehavior="false" Text="Button" /></div>

    Code:
    Get_Petroleum_Disbursement()
            Get_Petroleum_Receipt()
           
            Dim sender As Object
            Dim e As System.EventArgs
            Button11_Click(sender, e)
    Code:
    Protected Sub Button11_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button11.Click
    
            Dim mystr As String
            mystr = "I am here"
    
        End Sub
    Last edited by snufse; Jun 16th, 2010 at 11:00 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width