Here is the ListView I have for the products page:

<asp:ListView ID="list_view" runat="server" DataSourceID="SqlDataSource1">

        <table class="single_product">
                    <img src="<%# Eval("image") %>" />
                    <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' />
                    <asp:Label ID="descriptionLabel" runat="server" Text='<%# Eval("description") %>' />
                    <form action="comments.aspx" method="post">
                        <input type="hidden" name="prod_id" value="<%# Eval("prod_id") %>">
                        <input type="submit" name="prod_submit" class="button" value="View Comments">


The user can view the comments for a certain product by clicking the button, taking the prod_id over to the comments page.

Now here is the datasource for the comments page:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:username %>" 
        ProviderName="<%$ ConnectionStrings:username.ProviderName %>"
        InsertCommand="INSERT INTO comment (prod_id, comment_desc, username) VALUES (@prod_id, @comment_desc, @username)"
        SelectCommand="SELECT * FROM comment WHERE prod_id = prod_id ORDER BY comment_date DESC">
        <asp:Parameter Name="prod_id" Type="Int32" DefaultValue="2" />
        <asp:Parameter Name="comment_desc" Type="String"/>
        <asp:Parameter Name="username" Type="String" />

I want the select to be like this:

SelectCommand="SELECT * FROM comment WHERE prod_id = [value from previous page] ORDER BY comment_date DESC"

I have used Request.Form, etc. but no luck.

I also have other problems but I'll mention them once/if this is solved.

Thank you for any responses.

6 Years
Discussion Span
Last Post by matthewskyle

Try using Session. (C#)

private void Page_Load(object sender, System.EventArgs e)
         Session["prod_id"] = "value1";

private void Page_Load(object sender, System.EventArgs e)
        string prod_id = (string)(Session["prod_id"]);

<asp:SessionParameter SessionField="prod_id" DbType="String" Name="Product ID" />   

Edited by matthewskyle: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.