Okay, I was getting lot of emails about how to pass the data from the child window to the parent window. In the code below I pass the DataTable from the child window to the parent window. The child window has a datagrid and you select the items from the datagrid and those items are passed back to the parent window.

Parent Window:

protected void Page_Load(object sender, EventArgs e)
    {
        
        
if (Session["SelectedItems"] != null)
        {
            GridView1.DataSource = (DataTable)Session["SelectedItems"];
            GridView1.DataBind(); 
        }
    }

Child Window:

protected void Button1_Click(object sender, EventArgs e)
    {
                
            
// Make a datatable which will hold the values 
        
DataTable myTable = new DataTable();
        myTable.Columns.Add("CategoryID");
        myTable.Columns.Add("CategoryName");

        DataRow myRow = 
null

        
foreach (GridViewRow row in gvChild.Rows)
        {
            
bool result = ((CheckBox) row.FindControl("CheckBox1")).Checked;
            
if (result)
            {
                myRow = myTable.NewRow();
                myRow["CategoryID"] = row.Cells[0].Text;
                myRow["CategoryName"] = row.Cells[1].Text;
                myTable.Rows.Add(myRow); 
            }
        }        
        
        Session["SelectedItems"] = myTable;
        Button1.OnClientClick = "PassValues()";         
        
    }

And the javascript function PassValues():

<script language="javascript" type="text/javascript">

    function PassValues() 
    { 
    window.opener.document.forms(0).submit();
    self.close();
     
    }

</script>

There is however a problem with the above code. Which is that you need to press the button in the child window twice to get the window close and display the values on the parent window. If you figure out the solution then let me know :)

 

powered by IMHO