How to reload a page

  • Thread starter Thread starter riversmithco
  • Start date Start date
R

riversmithco

This should be easy,

How do I reload a page so that it makes the server think it's the first
time the page has been loaded?

Thanks
 
how ? do you want do reload and try to hidde this from the server ?
you mean, the page can reload just one time ? next time doesn't count, not ?
you can create a variable of int type = 0 and when reload i++

page_load event

int i = 0;
if (i > 1) //0 is the first time and 1 ist the second time{
do nothing
}else{
do your code
i++;
}

I don't know if it gonna work, but try...and i also don't know if that's the
best way!

see ya!


--

Atenciosamente,

Daniel Groh
CTF Technologies do Brasil Ltda.
Analista Programador
Fone: 11 3837-4203
E-mail: (e-mail address removed)
 
I have a bunch of Grids on a page that have their CurrentPageIndex set
at various positions. If a user reloads the page so that smaller
datasets come back those page sizes are still the same and are causing
errors. I simply need to clear the CurrentPageIndex and then reload
the page.

Make sense?
 
No, still doesn't make much sense.
What is CurrentPageIndex? Is that a variable of yours where are you storing
it?
So the only thing you're trying to accomplish is to clear CurrentPageIndex?
Or you have a some kind of a page or grid sizing problem?
Please be a little more specific.
 
Ok,

Here is what is happening.

1. I have a page with a datagrid. This datagrid enables paging which
is accomplished through the following line of code:
grdADData.CurrentPageIndex = e.NewPageIndex (this happens in the
Grid's PageIndexChanged event)

2. Now lets assume that when my grid is originally bound to a dataset,
it's a very large dataset so the user could likely page through it a
lot. To be more specific, let's say they page to the end. That grid
now holds a number reprenting how many pages it has iterated
over...remember, we are talking paging, not pages in the .aspx sense.
That page value is in the CurrentPageIndex property.

3. Now let's say the user wants to load that grid again with different
data, only this time there is a much smaller dataset. When Databind is
called, an error is thrown because the new dataset doesn't have as many
pages to go through so the index of the CurrentPageIndex is out of
bounds.

4. So, what needs to happen is that I need to do is clear that grid's
CurrentPageIndex should the user databind to a smaller dataset than the
one they had been paging through before.

5. At this point I realize that this is tedious.

6. The easiest way around this seems to me to just simply set the
CurrentPageIndex to 0 in an error handler and then reload the page. I
realize that I may not need the server to think it's the first load, I
just want to reload the page.

Hope that helps


Thanks for looking at this
 
You could use Response.Redirect("yourpagename.aspx"), though I'm sure
there's a better solution than this.

Mun
 
Hello Riversmith -

If I understand your problem correctly, the following may be of help:

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

dgDataGrid1.CurrentPageIndex = 0
FillDataGrid()
End Sub

Sub FillDataGrid()
'This is where you do the connection and dataset stuff to fill the grid
from the item selected in the DropDownList
End Sub

Sub NewPage(sender as Object, e As DataGridPageChangedEventArgs)
dgDataGrid1.CurrentPageIndex = e.NewPageIndex
FillDataGrid()
dgDataGrid1.DataBind
End Sub

Sandy
 
Duh,

Thank you Sandy for reminding me to look in the most obvious place for
an answer first!
 
Back
Top