MyBlog\Default.aspx
1. Open MyBlog\Default.aspx in Design view.
2. In the Content control type "Add/Edit My Blogs". Format this as
an H2 header. Place your cursor below the header and then select
the Layout | Insert Table menu command. Add a two-row, single-column
table with the properties set as you see below. Press Shift+Enter
to add a new line break. Repeat this step, adding a second table below the first.
3. In the first row of the upper table, type "New Blog Title:" and then press
Shift+Enter. From the Toolbox drag a TextBox
control under the text you just typed. Set its ID property to "BlogTitleTextBox"
and its Width property to "50%".
4. Press Shift+Enter to add a new line break. Type "New Message:"
and then press Shift+Enter. Drag a TextBox control
under the text you just typed. Set its ID property to "BlogMessageTextBox",
Width to "50%", TextMode to MultiLine,
and Rows to "4".
5. Into the second row of the first table drag a Button control.
Change its ID to "AddBlogButton" and its Text
property to "Add".
5. Double-click the Button to add a Click event
handler. To this handler add the following:
GeekSpeak.Blog.InsertBlog(BlogTitleTextBox.Text, BlogMessageTextBox.Text)
Response.Redirect("Default.aspx")
VB
6. Switch to Back to MyBlog/Default.aspx's Design view. In the first row of the second table
type "Show blogs at a time" (note
the extra spaces). Drag a DropDownList control
between "Show " and " blogs". In the DropDownList Tasks menu,
check Enable AutoPostBack and then click Edit Items.
Add the following items: "10", "25", and "50". Change the control's ID
property to "BlogsPerPageDropDownList".
7. Into the second row of the second table, drag an ObjectDataSource
control.
In the ObjectDataSource Tasks menu click Configure Data Source.
For Choose your business object select GeekSpeak.Blog,
and then click Next. In Define Data Methods, for
Choose a method select ListMyBlogs. Click Update
and select UpdateBlog. Click Delete and select
DeleteBlog. Click Finish. Finally, change the
control's ID property to "blogsObjectDataSource".
8. Drag a GridView control below the ObjectDataSource
control. In the GridView Tasks menu, for Choose Data Source
select blogsObjectDataSource. Check Enable Paging,
Enable Editing and Enable Deleting.
9. Click Edit Columns. In the Fields dialog, in
the Selected fields pane, select IsPublic and
then click the X button (Delete). Also delete DateCreated.
Select DateUpdated and set its DataFormatString
property to "{0:G}". Set the BlogID field's Visible
property to False, and then click OK.
10. In the GridView Tasks menu click Auto Format.
Select Simple and then click OK. Change the GridView
control's ID property to "BlogListGridView".
11. Click into the DataKeyNames property field and then click
... (Browse). Select BlogID, click >
(right arrow), and then click OK.
12. Double-click the DropDownList to create a SelectedIndexChanged
event handler. To
this handler add the following:
BlogListGridView.PageSize = Integer.Parse(BlogsPerPageDropDownList.SelectedValue.ToString())
VB