Force Gridview on parent web page to refresh

  • Thread starter SilkCityFlorida
  • Start date
S

SilkCityFlorida

I have a web page "PgA" with a GridView. I open another page "PgB" in a new
window. On PgB, they do some things that affect the underlying data for the
GridView on PgA. When the user is done with PgB, they click a button that
executes this VB:
Protected Sub Close_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Close.Click
'Do some stuff
Response.Write("<script language='javascript'> {
window.close();}</script>")
'What code goes here to force the GridView on PgA to refresh?
End Sub
Now, because some of what they did on PgB has affected the underlying data
for the GridView on PgA, I need to cause the GridView to refresh, without
reloading the entire page.
In VB, what code do I use?

I was able to use this:
opener.window.location=opener.window.location;self.close();

However, that causes the entire page to reload. I only want the GridView to
reload. Within Javascript on the Child page, can I somehow execute a
specific routine on the parent page? The routine contains the code I need to
execute.
 
C

Cor Ligthert[MVP]

Hi,

AspNet is not build to use popup or whatever other kind of seperate windows.

Cor
 
B

bwspell

I have a web page "PgA" with a GridView.  I open another page "PgB" in anew
window.  On PgB, they do some things that affect the underlying data forthe
GridView on PgA.  When the user is done with PgB, they click a button that
executes this VB:
     Protected Sub Close_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Close.Click
        'Do some stuff
        Response.Write("<script language='javascript'> {
window.close();}</script>")
        'What code goes here to force the GridView on PgA to refresh?
    End Sub
Now, because some of what they did on PgB has affected the underlying data
for the GridView on PgA, I need to cause the GridView to refresh, without
reloading the entire page.
In VB, what code do I use?

I was able to use this:
opener.window.location=opener.window.location;self.close();

However, that causes the entire page to reload.  I only want the GridView to
reload.  Within Javascript on the Child page, can I somehow execute a
specific routine on the parent page?  The routine contains the code I need to
execute.

I added an Input button to my page with this in the Page Load code
behind:
Dim strScript As String =
"<script>window.opener.document.forms(0).submit();</script>"
ClientScript.RegisterClientScriptBlock(Me.GetType, "script",
strScript)
This closes the popup window

Add a second ASP button that executes an update on your Grids
datasource i.e.

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

If Page.IsValid Then

'INSERT INTO yourdatabase (a, b, c) VALUES (@a, @b,
@c)
SqlDataSource2.InsertCommand = strSQL
SqlDataSource2.Insert()
Endif

End Sub

This will cause your Grid to update as the datasource has been updated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top