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.
Re: Show GridViews at Initial PageLoad
Quote:
Originally Posted by
snufse
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.
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
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.
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
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 :)
Re: Show GridViews at Initial PageLoad
i will use the option number 2 as a plus
good link out there
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
Re: Show GridViews at Initial PageLoad
Quote:
Originally Posted by
gep13
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
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.
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
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