Blog.aspx

1. Open Blog.aspx in Source view.

2. Just inside the Content type "<h2><%= MemberNameTitle %></h2>".

3. Switch to Design view and drag a SqlDataSource control in the Content control. In the SqlDataSource Tasks menu click Configure Data Source.

4. For Choose Your Data Connection select GeekSpeakConnectionString, and then click Next.

5. For Configure the Select Statement check Title, Message, DateUpdated and MemberAccountName. Click Order By. For Sort by select DateUpdated, and then select Descending. Click OK and then click WHERE. For Column select MemberAccountName, for Operator select =, for Source select QueryString, and for QueryString field type "un". Click Add, then click OK. Verify that your dialog looks like the following. Then click Next and Finish.

6. Change the SqlDataSource ID property to "blogsSqlDataSource". Drag a DataList control onto the page below the SqlDataSource control. In the DataList Tasks menu, for Choose Data Source, select blogsSqlDataSource.

Although you could use the ItemTemplate code that VWD automatically generates from the metadata of the selected data source, you will reuse the ASPX source from one of the supplied User Controls to keep a consistent look-and-feel.

7. Switch to Source view. In the Solution Explorer, under Controls, double-click LatestBlogs.ascx. Copy everything between the PlaceHolder control, as you see below. Switch back to Blogs.aspx and replace the existing content between the ItemTemplate tags with the copied content. Finally, change the DataList control's ID property to "blogsDataList" and set its Width property to "100%".

8. Switch to Design view. Your page should now appear as follows:

9. In the Solution Explorer, right-click Blog.aspx and select View Code. Inside the class add a public variable named "MemberNameTitle" of type String. To the Page_Load event handler add the following:


If Request("un") = "lookup" Then
    Response.Redirect("Blog.aspx?un=" + User.Identity.Name)
End If

If Not IsNothing(Request("un")) Then
    MemberNameTitle = Request("un") + "'s Blogs"
End If
VB

10. Press F5 to run the application. Click Member Blogs From the Master Page's main menu, and then click RodneyGuzman. Close your browser.

 
HyperLink HyperLink

Powered By ASP.NET v2.0