Hi maideen,
I have created sample please refer the below code.
Parent.aspx
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script type="text/javascript">
var popup;
function SelectName() {
popup = window.open("Popup.aspx", "Popup", "width=350,height=250");
popup.focus();
return false
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:Panel ID="Panel1" runat="server" DefaultButton="btnSearchProdDetails">
<asp:Label ID="Label18" runat="server" Text="Name"></asp:Label>
<asp:TextBox ID="txtItemID" runat="server" Enabled="true" ClientIDMode="Static"></asp:TextBox>
<asp:Button ID="btnSearchProdDetails" runat="server" Text="Search" OnClientClick="SelectName()" />
</asp:Panel>
</asp:Content>
Popup.aspx
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:Button ID="btnSelectName" runat="server" Text="select Name" OnClientClick="SetName();" />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="SelectedIndexChanged">
<Columns>
<asp:CommandField ShowSelectButton="True"></asp:CommandField>
<asp:BoundField DataField="Id" HeaderText="ID" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Country" HeaderText="Country" />
</Columns>
</asp:GridView>
<script type="text/javascript">
function SetName() {
if (window.opener != null && !window.opener.closed) {
var name = window.opener.document.getElementById("txtItemID");
name.value = document.getElementById("txtName").value;
}
window.close();
}
</script>
Popup.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Country",typeof(string)) });
dt.Rows.Add(1, "John Hammond", "United States");
dt.Rows.Add(2, "Mudassar Khan", "India");
dt.Rows.Add(3, "Suzanne Mathews", "France");
dt.Rows.Add(4, "Robert Schidner", "Russia");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
txtName.Text = row.Cells[2].Text;
}
Screenshot