views:

24

answers:

2

Afternoon all.

I have the following scenario:

I have a search page where by a client searches for a product from a drop down list, upon clicking a button, a gridview is produced display the spec.

What I would like is the functionality for the user to make their selection and a new window pops up with the spec.

So I have a simple code behind for the search page:

 protected void Button1_Click(object sender, EventArgs e)
        {
            Session["Product"] = DropDownList1.SelectedValue;

            string strScript = "window.open('GridViewPage.aspx', 'Key', 'height=500,width=800,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,titlebar=no');";

            ScriptManager.RegisterStartupScript(this, typeof(string), "", strScript, true);
        }

And a gridviewpage that presents the data based upon the session created in the search page:

 <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
        DataSourceID="LinqDataSource1">
        <Columns>
            <asp:BoundField DataField="Product" HeaderText="Product" 
                SortExpression="Product" />
            <asp:BoundField DataField="Spec" HeaderText="Spec" 
                SortExpression="Spec" />

        </Columns>
    </asp:GridView>

    <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
        ContextTypeName="GridViewInNewWindow.ProductDataContext" EntityTypeName="" 
        TableName="tblProducts" Where="Product == @Product">
        <WhereParameters>
            <asp:SessionParameter Name="Product" SessionField="Product" 
                Type="String" />
        </WhereParameters>
    </asp:LinqDataSource>

Now upon first iteration, this does the job...gridview presented in new window...hurrah! i.e. a user searches for egg, the spec for an egg is presented in a new window.

However, what I would like to happen is that the user can make multiple searches so a number of new windows are opened. i.e. a user searches for egg once, the spec is returned in a new window; they then wish to see the spec for a chicken, so they use the search page to find said chicken, click the button and another new window is shown displaying the chicken's specs.

Does anyone know how I can achieve this? Apologies if this is simple stuff, I am just finding my feet.

+2  A: 

Just change your window.open('GridViewPage.aspx', 'Key' .. code into using a unique window name per product - eg window.open('GridViewPage.aspx', 'product' + productId + '...

As it is now you are actually telling window.open to use the window named key, leading to it reuse the same window for all products.

Sean Kinsey
+2  A: 

The 2nd parameter for window.open is the name of your popup window. e.g. "Key"

Change it for each popup you want to create.

scunliffe