Refresh GridView from pop-up

  • Thread starter Thread starter David C
  • Start date Start date
D

David C

I have an asp.net web page that contains a GridView showing data from a
database. I have a LinkButton in one of the GridView columns that has
OnClientClick = "return opentask();" which opens a pop-up aspx page using
the following Javascript.

function opentasks(srecordid) {
var surl = 'JobTasks.aspx?rid=' + srecordid;
void window.open(surl, "_blank",
height=475,width=760,status=yes,toolbar=no,menubar=no,location=no");
return false;
}

What I would like to do is when the JobTasks.aspx (FormView) does an insert
or update I would like to refresh ( DataBind()? ) the GridView (named
gvOpenorders) on the calling page.

Is there an easy way to do this and if so, how? Thanks.

David
 
I have an asp.net web page that contains a GridView showing data from a
database. I have a LinkButton in one of the GridView columns that has
OnClientClick = "return opentask();" which opens a pop-up aspx page using
the following Javascript.

function opentasks(srecordid) {
var surl = 'JobTasks.aspx?rid=' + srecordid;
void window.open(surl, "_blank",
height=475,width=760,status=yes,toolbar=no,menubar=no,location=no");
return false;
}

What I would like to do is when the JobTasks.aspx (FormView) does an insert
or update I would like to refresh ( DataBind()? ) the GridView (named
gvOpenorders) on the calling page.

Is there an easy way to do this and if so, how? Thanks.

David

Not sure if this would qualify for best answer, but since you are
using JavaScript windows I'd go for the next approach.

Add a button or linkbutton to your calling page and attach an event
handler to it (use dblClick on it) - think you might even be able to
hide the button; not sure about that though, so better test is visible
first -
in that eventhandler refresh the data for the grid. Let's call the
button RefreshGridButton

In the JobTasks.aspx you add a JavaScript something like the next:
<script type="text/javascript">
<!--
if (window.opener != null)
{
try
{
window.opener.javascript:__doPostBack('RefreshGridButton','');
---> handle catch

Think it should work (pretty untested though)

..L.
 
Leon said:
Not sure if this would qualify for best answer, but since you are
using JavaScript windows I'd go for the next approach.

Add a button or linkbutton to your calling page and attach an event
handler to it (use dblClick on it) - think you might even be able to
hide the button; not sure about that though, so better test is visible
first -
in that eventhandler refresh the data for the grid. Let's call the
button RefreshGridButton

In the JobTasks.aspx you add a JavaScript something like the next:
<script type="text/javascript">
<!--
if (window.opener != null)
{
try
{
window.opener.javascript:__doPostBack('RefreshGridButton','');
---> handle catch

Think it should work (pretty untested though)

.L.

I will give that a try. I was even thinking of using an AJAX Timer control
to do a DataBind every xxx seconds that I could activate when I opened the
new window and then turned it off when I closed it. Not sure how I could
stop the Timer since it is on the "opener" page. Thanks.

David
 
Leon,

It did not like

window.opener.javascript:__doPostBack('RefreshGridButton','');

It said 'expected ;' as a page error and it was referencing the colon (:)
you have after the word javascript

David
 
Leon,

It did not like

window.opener.javascript:__doPostBack('RefreshGridButton','');

It said 'expected ;' as a page error and it was referencing the colon (:)
you have after the word javascript

David

ofcourse it didn't like it..
it's either:
function namehere()
window.opener.__doPostBack('RefreshGridButton','');


or <a
href"javascript:window.opener.__doPostBack('RefreshGridButton','');

but never :javascript inside the function

the :javascript states: this <a href == is a script call; which
script??: javascript

..L.
 
Leon said:
ofcourse it didn't like it..
it's either:
function namehere()
window.opener.__doPostBack('RefreshGridButton','');


or <a
href"javascript:window.opener.__doPostBack('RefreshGridButton','');

but never :javascript inside the function

the :javascript states: this <a href == is a script call; which
script??: javascript

.L.

Leon,
I changed it to below, but still no luck, however I am not getting any
errors. When I click the refresh button on the opener page it does refresh,
but not when I call it from this pop-up page. Below is my function I have in
the pop-up page.

function refreshorders() {
if (window.opener != null) {
window.opener.__doPostBack('LBtnRefreshOrders','');
}
}


David
 
Back
Top