//this is a parent page source file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ParentPage.aspx.cs" Inherits="ParentPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function OpenWindow() {
window.showModalDialog("childrefresh.aspx",
"mywindow", "menubar=0,resizable=0," +
"width=350,height=250,toolbars=0");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<b>List of suppliers:</b>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="id" HeaderText="Emp Id"></asp:BoundField>
<asp:BoundField DataField="ename" HeaderText="Emp Name"></asp:BoundField>
<asp:BoundField DataField="doj" HeaderText="Emp Doj"></asp:BoundField>
</Columns>
</asp:GridView>
<asp:LinkButton runat="server" OnClientClick="OpenWindow()"
ID="lnkNew" onclick="lnkNew_Click">Add more supplier
</asp:LinkButton>
</div>
</form>
</body>
</html>
//this is parent code file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class ParentPage : System.Web.UI.Page
{
Connection objcon = new Connection();
protected void Page_Load(object sender, EventArgs e)
{
// ClientScript.RegisterStartupScript(GetType(), "window.dialogArguments.location.reload(true)", "<script>window.close();</script>");
string scriptString = ("<script language='JavaScript'>window.opener.document.forms(0).submit();</script>");
if (!Page.ClientScript.IsClientScriptBlockRegistered(scriptString))
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"script", scriptString);
}
if (!IsPostBack)
{
//DataSet ds;"<script language='javascript')
//if (Session["ds"] == null)
//{
objcon.da = new SqlDataAdapter("select * from demo", objcon.con);
objcon.da.Fill(objcon.ds);
GridView1.DataSource = objcon.ds;
GridView1.DataBind();
//}
//else
//{
// ds = (DataSet)Session["ds"];
// GridView1.DataSource = ds;
// GridView1.DataBind();
//}
}
}
protected void lnkNew_Click(object sender, EventArgs e)
{
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ParentPage.aspx.cs" Inherits="ParentPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function OpenWindow() {
window.showModalDialog("childrefresh.aspx",
"mywindow", "menubar=0,resizable=0," +
"width=350,height=250,toolbars=0");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<b>List of suppliers:</b>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="id" HeaderText="Emp Id"></asp:BoundField>
<asp:BoundField DataField="ename" HeaderText="Emp Name"></asp:BoundField>
<asp:BoundField DataField="doj" HeaderText="Emp Doj"></asp:BoundField>
</Columns>
</asp:GridView>
<asp:LinkButton runat="server" OnClientClick="OpenWindow()"
ID="lnkNew" onclick="lnkNew_Click">Add more supplier
</asp:LinkButton>
</div>
</form>
</body>
</html>
//this is parent code file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class ParentPage : System.Web.UI.Page
{
Connection objcon = new Connection();
protected void Page_Load(object sender, EventArgs e)
{
// ClientScript.RegisterStartupScript(GetType(), "window.dialogArguments.location.reload(true)", "<script>window.close();</script>");
string scriptString = ("<script language='JavaScript'>window.opener.document.forms(0).submit();</script>");
if (!Page.ClientScript.IsClientScriptBlockRegistered(scriptString))
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"script", scriptString);
}
if (!IsPostBack)
{
//DataSet ds;"<script language='javascript')
//if (Session["ds"] == null)
//{
objcon.da = new SqlDataAdapter("select * from demo", objcon.con);
objcon.da.Fill(objcon.ds);
GridView1.DataSource = objcon.ds;
GridView1.DataBind();
//}
//else
//{
// ds = (DataSet)Session["ds"];
// GridView1.DataSource = ds;
// GridView1.DataBind();
//}
}
}
protected void lnkNew_Click(object sender, EventArgs e)
{
}
}
No comments:
Post a Comment