【发布时间】:2015-01-17 00:41:32
【问题描述】:
我正在尝试将选择查询的结果显示到网格视图中,但我无法让它工作:(。 这是我的桌子:
cartID userID productID
-------------------------------
001 A111111 file1
002 A111111 fileq
003 A222222 file2
004 A222222 file3
005 A111111 file4
006 A333333 file5
007 A333333 file6
这是查询的结果:
nomProduit prix
---------------------
batata 200
bicyclette 23
kawkaw 2
这是我的查询
SELECT Produits.nomProduit,Produits.prix
FROM [Products].[dbo].[shoppingCart],[Products].[dbo].[Produits]
WHERE produitID=Id and userID = @userID
这是我的 aspx 代码:
<asp:GridView ID="GridView1" runat="server" DataSourceID="shoppingCartDS" AllowSorting="True">
</asp:GridView>
<asp:SqlDataSource ID="shoppingCartDS" runat="server"
ConnectionString="<%$ ConnectionStrings:ProductsConnString %>" SelectCommand="selectPanier"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Name="userID" Type="String"/>
</SelectParameters>
</asp:SqlDataSource>
这是我的cs代码
protected void Page_Load(object sender, EventArgs e)
{
String strCurrentUserId = User.Identity.GetUserId();
shoppingCartDS.SelectParameters.Add("userid", DbType.Guid, strCurrentUserId.ToString());
}
请大家帮帮我:(
【问题讨论】:
标签: c# asp.net gridview webforms