我试图在源代码的查询中传递Request.QueryString整数值。我该怎么做?
http://localhost:3738/WebSite3/UserDetails.aspx?Id=43
我想在查询
中传递id的值,即43 <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SLIITComDBConnectionString %>"
SelectCommand="SELECT Album.AlbumID, Album.DefaultPhotID, Album.AlbumName, PhotAlbum.Photo FROM Album INNER JOIN PhotAlbum ON Album.DefaultPhotID = PhotAlbum.PhotoID where album.userid= **Request.QueryString[id]** ">
答案 0 :(得分:4)
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SLIITComDBConnectionString %>"
SelectCommand="SELECT Album.AlbumID, Album.DefaultPhotID, Album.AlbumName, PhotAlbum.Photo FROM Album INNER JOIN PhotAlbum ON Album.DefaultPhotID = PhotAlbum.PhotoID where album.userid= @userid ">
<SelectParameters>
<asp:QueryStringParameter Name="userid" Type="String" QueryStringField="id" />
</SelectParameters>
</asp:SqlDataSource>
答案 1 :(得分:0)
您可以使用:
<%=this.Request.QueryString["Id"]%>