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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redraw DataGrid From Javascript?

Status
Not open for further replies.

Robertio

Programmer
Oct 9, 2000
87
GB
Is there any way to redraw a datagrid from javascript?

Scenario:
One screen with a grid on it, last column is a hyperlink

User clicks on hyperlink and is taken to a screen with details about the selected row. This screen is a popup window with parameters passed to it (so it knows what to display) and is therefore called via javascript.

Having made any changes on this screen the user clicks OK or Cancel.
On Cancel the popup window should close and the user is presented with the grid on the main screen, no problems so far.
On OK the database should be updated, user returned to the main screen where the grid has been refreshed.

Before we made the detail window a popup it worked fine, but now it seems impossible to get it working the same way. Can get the detail window recognising OK/Cancel, passing this back along with any updated details, but we've then got these in a javascript function and no idea how to get them from there back to C# (so we can update the data and refresh the grid).

Any help/advice appreciated

Robertio
Alias: Robbie Calder
Software Developer
urc@walkermartyn.co.uk
 
Robertio:

Here is an aspx pop-up page which is sent parameters via QueryString and then forces a post-back on "Accept". The post-back forces a chart to re-draw. This is done by using Javascript to force a post-back on close - the update values are sent to invisible textboxes, and then the page post back to redraw (the chart is actuall sitting inside an IFRAME - but the concept is close to what you are working with).

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 background="images/lgtbrown.gif">
<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"].submit();
window.close();
}      
</script>
    <form id="frmY1" runat="server">
      <div align="center">
        <table border="1">
            <tr>
                <td align="Center" height="30px">
                   <b>Choose Y1 Max:</b><br>
                    <asp:TextBox id="txtY1Max" runat="server" width="50px"/>
                    <p>
                    <b>Choose Y1 Min:</b><br>
                    <b><asp:TextBox id="txtY1Min" runat="server" width="50px"/></p>
                    <p>
                    <b>Choose Y1 Interval:</b><br>
                    <b><asp:TextBox id="txtY1Int" runat="server" width="50px"/></p>
                    </p>
               </td>
            </tr>
            <tr>
                <td align="Center" height="30px">
                  <p><INPUT TYPE="button" VALUE="Accept" onClick="javascript:ReturnY1(document.frmY1.txtY1Max.value, document.frmY1.txtY1Min.value, document.frmY1.txtY1Int.value)" style="font-size: 14px; font-weight: bold; color: #0000FF;" width="60px"> </b></Font>
                </td>
            </tr>
        </table>
     </div>
    </form>
</body>
</html>

...hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top