Hi all,
I have a parent window contains a Textbox and input button controls. And child window contains a Gridview control & Textbox.
I want to pass the value from the child window to parent window whenever I select the record from the gridview of the child window. and child window must be closed after select the record from the gridview control.
In my code I am passing the parameter from parent to child window.
Here is my Code:
Parent Window:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Parent Window</title>
<script type="text/javascript" language="javascript">
function showChildWin()
{
var MyValue=document.getElementById('txt_name').value;
var myUrl = 'Popup.aspx?myVal='+MyValue;
window.showModalDialog(myUrl,'My APPs','status:no; dialogWidth:630px; dialogHeight:420px; help:no; scroll:no; menubar:no; resizable:no');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
<div style="text-align: center">
<br />
<asp:TextBox ID="txt_name" runat="server">
<br />
<br />
<br />
<input id="Button1" type="button" önclick="showChildWin()" value="Open Child Window" /></div>
<br />
</div>
</form>
</body>
</html>
Child Window:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Child Window</title>
<script language="javascript" type="text/javascript">
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<contenttemplate>
<div style="text-align: center">
<br />
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" AllowPaging="true"
GridLines="None" Height="67px"
style="font-family: Verdana; font-size: 10pt"
onselectedindexchanged="GridView1_SelectedIndexChanged" Width="345px">
<columns>
<asp:CommandField ShowSelectButton="true"/>
</columns>
<rowstyle backcolor="#F7F6F3" forecolor="#333333" />
<footerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White" />
<pagerstyle backcolor="#284775" forecolor="White" horizontalalign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<editrowstyle backcolor="#999999" />
<alternatingrowstyle backcolor="White" forecolor="#284775" />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server">
<br />
</div>
</contenttemplate>
</form>
</body>
</html>
CodeBehind of Child Window:
protected void Page_Load(object sender, EventArgs e)
{
string str_val = Request.QueryString[0].ToString();
TextBox1.Text = str_val;
SqlDataAdapter da = new SqlDataAdapter("select address from tblEmpDetails", con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text=GridView1.SelectedRow.Cells[1].Text;
}
Help me please.......
I need your help as soon as possible........