I am trying to pull content into a content page (within a master page) by using url query strings. I have got the code to pull the query string in and it is working fine. I am having trouble creating my sql Select Command using a variable. My sql Select Command works fine if I hard code it - I am just having trouble with how to reference the variable. I am sorry I am very new to this so I am probably doing something really stupid wrong but I need to be able to move on and put this one behind me.
Thanks for any and all help,
Tim
Here is the code I currently have - I know it is wrong (really wrong) but I left it this way so you could see what I am trying to do:
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="Headers">
<script runat="server">
Sub UrlDecode()
Dim StrToDecode As String
Dim StrToReturn As String
Dim SelectStatement As String
StrToDecode = Request.QueryString(
"pgid")
StrToReturn = Server.UrlDecode(StrToDecode)
SelectStatement =
"SELECT * FROM [SiteContent]WHERE TextId = " + StrToReturn
Response.Write(SelectStatement)
' Response.Write(StrToReturn)
' SELECT * FROM [SiteContent]WHERE TextId = 0
End Sub
</
script>
</
asp:Content>
<
asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
<
asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Personal %>"
SelectCommand="<% UrlDecode %>"></asp:SqlDataSource>
<!-- SelectCommand="SELECT * FROM [SiteContent]"></asp:SqlDataSource> -->
<
div id="content">
<asp:DataList ID="DataList1" runat="server"
DataSourceID="SqlDataSource1">
<ItemTemplate>
<p><%#Eval("Body_Content")%></p>
</ItemTemplate>
</asp:DataList>
</
div>
<% UrlDecode %>
</
asp:Content>