Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update record in other page and refresh the page with the grid when fi

Status
Not open for further replies.

jbpr

Programmer
May 5, 2006
6
PR
Hi I have a page with a datagrid, to make updates I used other page but I want open the edit page in a popup windows ,and when I click save close the page and refresh the grid in the firts page.
 
You will need to use javascript. Create a function in the <script> tags in the <HEAD> tags in your HTML of the page(pop up page). Call
window.opener.location = 'your page.aspx'
self.close;
return false;

This should cause the calling page to be reloaded. If not, try asking the JavaScrip forum.

Jim
 
Jim - one point - would it be best to open a child window to send/retrieve variables? In your approach I think perhaps calling the aspx page can be carried out carrying a return QueryString and so should work fine (haven't tested it). I have seen in a few cases where pop-up windows are opened using the following approach:
Code:
function GetDate(CtrlName, SampleDate){   
  ChildWindow = window.open('qwwCalendar.aspx?FormName=' + document.forms[0].name + '&CtrlName=' + CtrlName + '&SampleDate=' + SampleDate, "PopUpCalendar", "width=270,height=300,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no");    
}
Just thought I'd throw this up..of course this could be quickly answered over at the Javascript forum -
 
Im just thinking in open a new windows with js(window.open) and in the windows use autoclose and then call the prerender event of datagrid to refresh. the thing is I dont know how to do.
 
jbpr: The technique I have used in this scenario is that I send the new variables back from the pop-up and populate hidden textboxes and then on reload the Datagrid picks up the new SQL parameters there. I can give you my approach in its totality if you'd like.
 
jbpr: You can probably use either approach regarding opening the pop-up. Here's what I would do on this (which is only 1 way and perhaps not the best but it works).

Using the code above I open up the pop-up window; in the above case its a calendar but could be any form taking in variables.

The code for the pop-up (I'll leave the calendar stuff in just for completeness) is as follows (the aspx page):
Code:
<%@ Page Language="VB"%>
<%@Import Namespace = "Microsoft.VisualBasic"%>
<%@Import Namespace = "System"%>
<%@Import Namespace = "System.Web"%>
<%@Import Namespace = "System.Web.UI"%>
<%@Import Namespace = "System.Web.UI.WebControls"%>
<%@Import Namespace = "System.Web.UI.HtmlControls"%>
<script runat="server">
Sub Page_Load(Sender As Object, e As EventArgs) 
 If Not IsPostBack Then 
  txtY1Max.Text = Request.QueryString("Y1Max")
  txtY1Min.Text = Request.QueryString("Y1Min")
  txtY1Int.Text = Request.QueryString("Y1Int")
 End If
End Sub
</script>
<html>
<head>
<title>Adjust Y1 axis</title>
</head>
<body bgcolor="#FFFF99">
<script language="Javascript">
function ReturnY1(Y1Max, Y1Min, Y1Int){
var Y1Max;
var Y1Min;
var Y1Int;
window.opener.document.forms["frmChemHist"].elements["txtY1Max"].value = Y1Max;
window.opener.document.forms["frmChemHist"].elements["txtY1Min"].value = Y1Min;
window.opener.document.forms["frmChemHist"].elements["txtY1Int"].value = Y1Int;
window.opener.document.forms["frmChemHist"].elements["AdjustY1"].value = 1;
window.opener.document.forms["frmChemHist"].submit();
window.close();
}      
</script>
<Form id="frmY1" runat="server">
<b><Font color="navy">Adjust Y1 Max:&nbsp;&nbsp;</b><asp:TextBox id="txtY1Max" runat="server" width="50px"/></Font><br>
<b><Font color="navy">Adjust Y1 Min:&nbsp;&nbsp;&nbsp;</b><asp:TextBox id="txtY1Min" runat="server" width="50px"/></Font><br>
<b><Font color="navy">Adjust Y1 Int:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:TextBox id="txtY1Int" runat="server" width="50px"/></Font>
<p align="center"><INPUT TYPE="button" VALUE="Accept" onClick="javascript:ReturnY1(document.frmY1.txtY1Max.value, document.frmY1.txtY1Min.value, document.frmY1.txtY1Int.value)" style="font-size: 14px; width: 90px; font-weight: bold; color: #0000FF;"></p>
</Form>
</body>
</html>

Now, when the button is clicked on the popup I send back the variables to the parent window. Note that the code above (java) causes the parent form to submit. As you can see the variables are first saved to textboxes on the parent form (you can set style="display:hidden"; also, frmChemHist is the name of the form on the parent page) and then in the DataGrid on DataBind I just use the text values in the SQL generating the DataGrid after postback. At the FAQ page here there is a list of options for picking up textbox values from a DataGrid. Let me know how things are going on this; we'll get it figured out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top