📄 maillist.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MailList : Base
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DGroup.BindControl(ref ddlGroup, "");
DGroup.BindControl(ref ddlGroupAdd, "");
bindMailList(0);
}
}
private void bindMailList(int groupID)
{
gvList.DataSource=DMailList.GetList(groupID);
gvList.DataBind();
}
protected void btnSearch_Click(object sender, EventArgs e)
{
bindMailList(int.Parse(ddlGroup.SelectedValue));
}
protected void gvList_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
gvList.PageIndex = e.NewSelectedIndex;
bindMailList(int.Parse(ddlGroup.SelectedValue));
}
protected void btnAdd_Click(object sender, EventArgs e)
{
if (txtAdd.Text.Trim().Length > 0)
{
DMailList.Add(txtAdd.Text, int.Parse(ddlGroupAdd.SelectedValue));
bindMailList(int.Parse(ddlGroup.SelectedValue));
txtAdd.Text = "";
}
}
protected void gvList_RowEditing(object sender, GridViewEditEventArgs e)
{
gvList.EditIndex = e.NewEditIndex;
bindMailList(int.Parse(ddlGroup.SelectedValue));
}
protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
DMailList.Delete(int.Parse(gvList.Rows[e.RowIndex].Cells[0].Text));
bindMailList(int.Parse(ddlGroup.SelectedValue));
}
protected void gvList_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow gvr= gvList.Rows[e.RowIndex];
int ID = int.Parse(gvr.Cells[0].Text);
string name = ((TextBox)gvr.Cells[2].Controls[0]).Text;
string groupID = ((DropDownList)gvr.Cells[1].FindControl("ddlEdit")).SelectedValue;
DMailList.Edit(name,int.Parse(groupID),ID);
gvList.EditIndex = -1;
bindMailList(int.Parse(ddlGroup.SelectedValue));
}
protected void gvList_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvList.EditIndex = -1;
bindMailList(int.Parse(ddlGroup.SelectedValue));
}
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
{
DataRowView drv = (DataRowView)e.Row.DataItem;
DropDownList ddl = (DropDownList)e.Row.Cells[1].FindControl("ddlEdit");
DGroup.BindControl(ref ddl, drv["GroupID"].ToString());
}
}
protected void gvList_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvList.PageIndex = e.NewPageIndex;
bindMailList(int.Parse(ddlGroup.SelectedValue));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -