Adding the Topic.aspx Page 
The next thing we need to do is add our page that will display the posts for a given topic. To do this, we will be pulling posts from our Posts table based on their associated TopicId. The way we will pass the TopicId to the Topic.aspx page is via a query string. To begin:
  1. Right click the project in your Solution Explorer.
  2. Select Add New Item…
  3. Select a Web Form and name it Topic.aspx.
  4. Ensure that the Select master page checkbox is checked and click Add.
  5. Select the MasterPage.master we added earlier and click OK.
Yes, it is possible to find a good web host. Sometimes it takes a while. After trying several, we went with Server Intellect and have been very happy. They are the most professional, customer service friendly and technically knowledgeable host we’ve found so far.
We will be using a repeater with a table in it, similar to what we did in the Default.aspx page to display links to all of the different posts on our page. To add the repeater, open Topic.aspx up to Design mode and:
  1. Expand the Data tab in your toolbox.
  2. Drag and drop a Repeater into the ContentPlaceHolder1 on the Web Form.
  3. Expand the Repeater Tasks Menu.
  4. In the Choose Data Source DropDownList, select <New Data Source…>.
  5. In the Data Source Configuration Wizard, select a Sql Database and click OK.
  6. It will now prompt you to choose your data connection, in the DropDownList select the ForumDBConnectionString we added earlier.
  7. Next, we need to configure the Select Statement, to do this select the Posts table from the Name DropDownList.
  8. Click the WHERE… to add a Where clause.
  9. Set the Column to TopicId.
  10. Set the Operator to =.
  11. Set the Source to QueryString.
  12. Set the QueryString field to id.
  13. Click Add.
  14. Click OK.
  15. Click ORDER BY…
  16. Set the Sort by DropDownList to PostDateTime and choose Descending.
  17. Click OK.
  18. Click Next.
  19. Click Finish.
We migrated our web sites to Server Intellect over one weekend and the setup was so smooth that we were up and running right away. They assisted us with everything we needed to do for all of our applications. With Server Intellect’s help, we were able to avoid any headaches!
Next, we need to format this repeater to output links to our posts in a table, as well as display who made the post and at what time. To do this open up Topic.aspx to Source mode and:
  1. In the Repeater tags, add the following code for the header:
    Code Block
    Topic.aspx
    The header.
    <HeaderTemplate>
        <table border="1" width="800px" cellpadding="5px">
        <tr>
            <td colspan="2">
                <a href="NewPost.aspx?id=<%= Request.QueryString["id"] %>">New Post</a>
            </td>
        </tr>
    </HeaderTemplate>
  2. Under the HeaderTemplate tag, add in the following code for the items:
    Code Block
    Topic.aspx
    The items.
    <ItemTemplate>
    
        <tr>
            <td>
                <a href="Post.aspx?id=<%# Eval("PostId") %>"><%# Eval("PostTitle"%></a>
            </td>
            <td>
                By: <%# Eval("PostUserName"%> @ <%# Eval("PostDateTime").ToString() %>
            </td>
        </tr>
                    
    </ItemTemplate>
  3. Under the ItemTemplate tag, add in the following code for the footer:
    Code Block
    Topic.aspx
    The footer.
    <FooterTemplate>
        </table>
    </FooterTemplate>
What this has done is setup a table with a header that links to a NewPost page and passes the TopicId as a query string. Then, we add in the ItemTemplate which will contain a column for a link to the Post page passing the PostId as a query string and displaying the PostTitle. Also, there is a column that displays the username and time the user posted it. Finally, we end the table tag in the footer.
At this point we need to test this out, but first we need to add some sample posts into our Posts table to be displayed on this page. For this, I am going to add in a few entries to the Post table, with a TopicId of 1 which corresponds to the General Discussion topic so that we will see them when we click the General Discussion link on our home page. To do this:
  1. Open up the Server or Database Explorer.
  2. Right click the Posts table and select Show Table Data.
  3. Add in the following entries:
    PostIdTopicIdPostTitlePostUserNamePostDateTime
    11Introductionsadmin1/1/2001 12:00:00 AM
    21Forum Guidelinesadmin1/1/2001 12:00:00 AM
    31Interesting Linksadmin1/1/2001 12:00:00 AM
If you’re ever in the market for some great Windows web hosting, try Server Intellect. We have been very pleased with their services and most importantly, technical support.
Now that we have some content, let’s test this out. Go ahead and load up the Default.aspx page and click on the General Discussion link. You should be linked to your Topic.aspx page that looks similar to this: 
 
This is pretty much it for the Topic page, next we need to create the Post page that the posts link to. 
ASPdotNET Forums Website Tut