Latest Source Code (1/1/2010 အထိ) http://www.sendspace.com/file/uxkj6h
ကြၽန္ေတာ္ အလြယ္ဆံုးလို႔ ထင္တဲ႔ project ထဲကို About Page ထည့္တဲ႔ အပိုင္းေလးကို အရင္ဆံုး စလုပ္လိုက္ပါတယ္။ project ထဲကို AboutMe.aspx page ေလး ထည့္လိုက္ျပီး။ About မွာ ျပမယ့္ message ေတြအတြက္ entry အပိုင္း က မလုပ္ရေသးေတာ့။ စာသားေတြကို ဒီတိုင္းပဲ Page ထဲကို ထည့္ျပလိုက္ပါတယ္။ comment ေပးတဲ႔ အပိုင္းေလးေရးဖို႔အတြက္၊ Database ထဲမွာ Comments Table သြားေဆာက္လုိက္ပါတယ္။
| Column Name | Data Type | Allow Nulls |
| CommentID | int | Unchecked |
| PostID | int | Checked |
| MemberID | int | Checked |
| CommentTitle | nvarchar(500) | Checked |
| CommentText | nvarchar(MAX) | Checked |
| CommentTime | datetime | Checked |
| CommentAuthorName | nvarchar(50) | Checked |
| CommentAuthorLocation | nvarchar(50) | Checked |
ကြၽန္ေတာ္က DataBase နဲ႔ ခ်ိတ္တဲ႔ ေနရာမွာ objectdatasource ကိုပဲ သံုးမွာ မို႔လို႔ DataSet လည္းေဆာက္ေပးဖို႔လိုပါေသးတယ္။ ျပီးရင္ comment entry အတြက္ textbox ေလးေတြထည့္တယ္။ Validation အတြက္ requirefield validator နဲ႔ email format အတြက္ Regularexpression validator controls ေတြကို ထည့္ထားပါတယ္။ send button ႏွိပ္ရင္ server သြားတဲ႔ အလုပ္ကို updatepanel ထဲမွာ ပဲ ထည့္ေပးလိုက္ပါတယ္။
Comment list ျပန္ျပဖို႔အတြက္ေတာ့ gridview control ကိုပဲ သံုးျပီး object datasource နဲ႔ ခ်ိတ္ျပလိုက္ပါတယ္။ ဒီ page ေလးက ရွင္းပါတယ္။ ကုဒ္လည္း သိပ္မရႈပ္ဘူး။
public partial class AboutMe : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Title = "About Page : sevenlamp.co.cc";
ShowCommentCount();
}
private void ShowCommentCount()
{
DataSet_CommentTableAdapters.CommentsTableAdapter adp = new DataSet_CommentTableAdapters.CommentsTableAdapter();
int commentCount = (int)adp.GetCommentCountByPostID(0);
if (commentCount == 0)
lblTotalComment.Text = "No Comment";
else if (commentCount == 1)
lblTotalComment.Text = commentCount.ToString() + " Comment";
else
lblTotalComment.Text = commentCount.ToString() + " Comments";
}
protected void SendButton_Click(object sender, EventArgs e)
{
ObjectDataSource2.Insert();
}
protected void ObjectDataSource1_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
{
e.InputParameters["CommentTime"] = DateTime.Now;
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((Label)e.Row.FindControl("lblCommentNo")).Text = "#" + (e.Row.RowIndex+1).ToString();
}
}
protected void ObjectDataSource2_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
{
ShowCommentCount();
GridView1.DataBind();
}
}