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:

 

C# VB  
GeekSpeak.Blog.InsertBlog(this.BlogTitleTextBox.Text, this.BlogMessageTextBox.Text);
            Response.Redirect("Default.aspx");
            

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)//<形状如"X"状的按钮,即是删除按钮>. 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<是指控件GridView 拥有的属性,点开这个属性你就可以看到"..."符号,用于打开窗口对话框> 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:

C# VB  
this.BlogListGridView.PageSize = int.Parse(this.BlogsPerPageDropDownList.SelectedValue.ToString());
            
 

posted on 2007-04-16 15:36  改变热爱  阅读(247)  评论(0)    收藏  举报

导航