How to add value to parent form drop down list from popup form? RRS feed

  • Question

  • ·         Hi,

    ·          I need to add items to parent forms drop down list from popup page. Popup page has a gridview and in gridview beside each row there is a select button. On click of select button the text should come and add in the parent page drop down list from popup page. By my code it just add one empty string in the drop down list.

    Please let me know what am i doing wrong here?

    I used the below code.

    In Pop up page


    @ Page Language="C#" AutoEventWireup="true" CodeFile="Country.aspx.cs" Inherits="Country" %>



    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">


    <script language="javascript">


    function GetRowValue(val)



    var ddl = window.opener.document.getElementById("cbRegCountry");


    var optn = document.createElement("OPTION");


    ddl.options[ddl.options.length + 1] = optn;

    optn.text =


    optn.value = 1;












    <form id="form1" runat="server">


    <asp:SqlDataSource ID="SqlDataSource1" runat="server"


    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"


    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"


    SelectCommand="SELECT CountryName FROM TBL_Country" />


    <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound">








    <asp:Button ID="btnSelect" runat="server" Text="Select" />






    <asp:Button ID="btnSelect" runat="server" Text="Select" />


















    The Parent page code for the button click



    void btnMoreCountry_Click(object sender, EventArgs e)



    if (IsPostBack)



    this.btnMoreCountry.Attributes.Add("onclick", "javascript:return PopupCountry()");




    Friday, April 30, 2010 10:00 AM