Adding the Post.aspx PageThe next thing that we need to do is add our Post page that will display all of the comments from the Comments table for a given PostId. To begin:
  1. Right click the project in your Solution Explorer.
  2. Select Add New Item…
  3. Select a Web Form and name it Post.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.
Similar to the other pages, we will be using a repeater to display all of the comments given a PostId. To add the repeater, open Post.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 Comments table from the Name DropDownList.
  8. Click WHERE… to add a Where clause.
  9. Set the Column to PostId.
  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 CommentDateTime and choose Descending.
  17. Click OK.
  18. Click Next.
  19. Click Finish.
We are using Server Intellect and have found that by far, they are the most friendly, responsive, and knowledgeable support team we’ve ever dealt with!
Next, we need to format this repeater to output all of the comments given a PostId into a neat table. To do this, open up the Post.aspx to Source mode and:
  1. In the Repeater tags, add the following code for the header:
    Code Block
    Post.aspx
    The header.
    <HeaderTemplate>
        <table border="1" width="800px" cellpadding="5px">
    </HeaderTemplate>
  2. Under the Header Template tag, add in the following code for the items:
    Code Block
    Post.aspx
    The items.
    <ItemTemplate>
        <tr>
            <td align="right">
                By: <%# Eval("CommentUserName"%> @ <%# Eval("CommentDateTime"%>
            </td>
        </tr>
        <tr>
            <td>
                <%# Eval("CommentMessage"%>
            </td>
        </tr>
    </ItemTemplate>
  3. Under the ItemTemplate tag, add in the following code for the footer:
    Code Block
    Post.aspx
    The footer.
    <FooterTemplate>
        <tr>
            <td>
                <a href="NewComment.aspx?id=<%= Request.QueryString["id"] %>">Comment</a>
            </td>
        </tr>
        </table>
    </FooterTemplate>
What this has done is created a table, and populated it with two rows for each comment, first a row to show the user and date of the comment and then to show the actual message. Then, we have added a footer with a link to the New Comment page that we will add later and pass the PostId as a query string to that page.
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.
At this point, we need to test this out. However, we don’t have any comments in our database so we will need to add a few manually. To do this:
  1. Open up the Server or Database Explorer.
  2. Right click the Comments table and select Show Table Data.
  3. Add in the following entries: 
    CommentIdPostIdCommentUserNameCommentMessageCommentDateTime
    11adminHello I’m admin1/1/2001 12:00:00 AM
    21joeHello I’m joe1/1/2001 12:00:00 AM
Now that we have come content, let’s test this out. Go ahead and load up the home page and navigate to General Discussion -> Introductions. You should see something like this:
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.
That is pretty much it for the Past page, next we need to add some functionality to our New Post and Comment links.
ASPdotNET Forums Website Tut