温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:BlogEngine v1.3 多皮肤多语言版源码
当前文件路径:BlogEngine/admin/Pages/PingServices.aspx.cs

1Using 13
14
public partial class admin_Pages_PingServices : System.Web.UI.Page 15
{ 16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
if (!Page.IsPostBack) 19
{ 20
BindGrid(); 21
} 22
23
grid.RowEditing += new GridViewEditEventHandler(grid_RowEditing); 24
grid.RowUpdating += new GridViewUpdateEventHandler(grid_RowUpdating); 25
grid.RowCancelingEdit += delegate { Response.Redirect(Request.RawUrl); }; 26
grid.RowDeleting += new GridViewDeleteEventHandler(grid_RowDeleting); 27
btnAdd.Click += new EventHandler(btnAdd_Click); 28
btnAdd.Text = Resources.labels.add + " ping service"; 29
} 30
31
void btnAdd_Click(object sender, EventArgs e) 32
{ 33
StringCollection col = BlogService.LoadPingServices(); 34
string service = txtNewCategory.Text.ToLowerInvariant(); 35
if (!col.Contains(service)) 36
{ 37
col.Add(service); 38
BlogService.SavePingServices(col); 39
} 40
Response.Redirect(Request.RawUrl); 41
} 42
43
void grid_RowDeleting(object sender, GridViewDeleteEventArgs e) 44
{ 45
string service = grid.DataKeys[e.RowIndex].Value.ToString(); 46
StringCollection col = BlogService.LoadPingServices(); 47
col.Remove(service); 48
BlogService.SavePingServices(col); 49
Response.Redirect(Request.RawUrl); 50
} 51
52
void grid_RowUpdating(object sender, GridViewUpdateEventArgs e) 53
{ 54
string service = grid.DataKeys[e.RowIndex].Value.ToString(); 55
TextBox textbox = (TextBox)grid.Rows[e.RowIndex].FindControl("txtName"); 56
57
StringCollection col = BlogService.LoadPingServices(); 58
col.Remove(service); 59
col.Add(textbox.Text.ToLowerInvariant()); 60
BlogService.SavePingServices(col); 61
62
Response.Redirect(Request.RawUrl); 63
} 64
65
void grid_RowEditing(object sender, GridViewEditEventArgs e) 66
{ 67
grid.EditIndex = e.NewEditIndex; 68
BindGrid(); 69
} 70
71
private void BindGrid() 72
{ 73
StringCollection col = BlogService.LoadPingServices(); 74
StringDictionary dic = new StringDictionary(); 75
foreach (string services in col) 76
{ 77
dic.Add(services, services); 78
} 79
80
grid.DataKeyNames = new string[] { "key" }; 81
grid.DataSource = dic; 82
grid.DataBind(); 83
} 84
85
} 86





}