📄 includefileclass.aspx.cs
字号:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DNNLite.Manage;
public partial class Manage_IncludeFileClass : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindClass();
}
}
private void BindClass()
{
IncludeFileClass[] cls = IncludeFileClass.FindAll(IncludeFileClass.Asc("Id"));
grdIncludeFileClass.DataSource = cls;
grdIncludeFileClass.DataBind();
}
protected void btnAddClass_Click(object sender, EventArgs e)
{
try
{
IncludeFileClass c = new IncludeFileClass();
c.ClassName = txtIncludeFileClass.Text;
c.EName = txtEName.Text;
if (c.IsValid())
{
c.CreateAndFlush();
BindClass();
}
else
{
lblerr.Text = c.ValidationErrorMessages[0];
}
}
catch (Exception ex)
{
lblerr.Text = ex.Message;
}
}
protected void grdIncludeFileClass_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdIncludeFileClass.PageIndex = e.NewPageIndex;
BindClass();
}
protected void grdIncludeFileClass_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
try
{
IncludeFileClass c = IncludeFileClass.Find( grdIncludeFileClass.DataKeys[e.RowIndex ].Value );
c.DeleteAndFlush();
BindClass();
}
catch (Exception ex)
{
lblerr.Text = ex.Message;
}
}
protected void grdIncludeFileClass_RowEditing(object sender, GridViewEditEventArgs e)
{
grdIncludeFileClass.EditIndex = e.NewEditIndex;
BindClass();
}
protected void grdIncludeFileClass_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
grdIncludeFileClass.EditIndex = -1;
BindClass();
}
protected void grdIncludeFileClass_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox txt = grdIncludeFileClass.Rows[e.RowIndex].Cells[1].Controls[0] as TextBox;
TextBox txte = grdIncludeFileClass.Rows[e.RowIndex].Cells[2].Controls[0] as TextBox;
if (txt == null ||txte==null )
{
lblerr.Text = "发生了意料之外的错误";
return;
}
try
{
IncludeFileClass c = IncludeFileClass.Find( grdIncludeFileClass.DataKeys[e.RowIndex ].Value );
c.ClassName = txt.Text;
c.EName = txte.Text;
if (c.IsValid())
{
c.UpdateAndFlush();
grdIncludeFileClass.EditIndex = -1;
BindClass();
}
else
{
lblerr.Text = c.ValidationErrorMessages[0];
}
}
catch (Exception ex)
{
lblerr.Text = ex.Message;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -