I have a table with threads for a forum, the thread name is a link and once clicked it passes the thread_id to the comments page, I need to know how to then display all the comments with the thread_id that is passed?
Have tried:
<asp:SqlDataSource ID="CommentsDataSource" runat="server"
SelectCommand="select * from comments where thread_id=@thread_id" >
<SelectParameters>
<asp:QueryStringParameter Name="@thread_id" QueryStringField="thread_id" Runat="Server" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:BoundField DataField="comment" HeaderText="Comment" />
</Columns>
</asp:GridView>
but it doesn’t work
Thanks
You can use a parameter in your datasource that reads from the QueryString. For example, here is a
SqlDataSourcewhich usesthread_idquerystring parameter (assuming your link navigates to something likeComments.aspx?thread_id=123: