开发者

passing more then one value with the querystring with the same id

I have a datalist that I want to list the Products that are comming from the Querystring. It works like this: Default.aspx/?ProductID=1 I get 1 product like I want. But I want to add more products like this Default.aspx/?ProductID=1,15,25 and get three products back. How do I make that to work?

<asp:DataList ID="DataList1" runat="server">
    <ItemStyle VerticalAlign="Top" />
    <ItemTemplate>
        <a href="../Product/Default.aspx?ProductID=<%#Eval("ProductID") %>">
            <asp:Label ID="lblName" runat="server" Text='<%#Eval("Name") %>' />
            <asp:Label ID="lblPrice" runat="server" Text='<%#Eval("Price") %>' />
        </a>
    </ItemTemplate>
</asp:DataList>


  protected void Page_Load(object sender, EventArgs e)
{
    string id = Request.QueryString["ProductI开发者_StackOverflowD"];

    DataTable table = CategoryAccess.GetList(id);

    list.DataSource = table;
    list.DataBind();     
}


ALTER PROCEDURE GetList
@ProductID INT

AS
SELECT ProductID, Name, Price 
FROM Product
WHERE (ProductID = @ProductID)


You can have:

/page.aspx?ProductID=1&ProductID=15&ProductID=25

Then Request.Querystring("ProductID") will return 1,15,25

This can then be put into an ArrayList like Request.Querystring("ProductID").split(",")

Passing those 3 values as a parameter is a bit more tricky though, youre probably best passing it as xml:

Passing multiple values for one SQL parameter

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜