本次使用GridView是工厂模式下 无极限分类
GridView详解
1.GridView前台分析
2.GridView分页讲解
3.GridView绑定,编辑,更新,取消,删除,排序
GridView绑定,编辑,更新,取消,删除,排序
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Bind();
}
//绑定
public void Bind()
{
ViewState["SortOrder"] = "Id";
ViewState["OrderDire"] = "asc";//这两句话是为了 排序绑定引用实例 先赋值
ddg.BLL.FenLei bfenlei = new ddg.BLL.FenLei();
DataSet ds = new DataSet();
ds = bfenlei.GetAllList();
gvwFenLei.DataSource = ds;
gvwFenLei.DataKeyNames = new string[] { "Id" };//设置主键字段
gvwFenLei.DataBind();
}
//删除
protected void gvwFenLei_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
ddg.Model.FenLei mfenlei = new ddg.Model.FenLei();
ddg.BLL.FenLei bfeilei = new ddg.BLL.FenLei();
mfenlei = bfeilei.GetModel(int.Parse(gvwFenLei.DataKeys[e.RowIndex].Value.ToString()));<
GridView详解
1.GridView前台分析
2.GridView分页讲解
3.GridView绑定,编辑,更新,取消,删除,排序
GridView绑定,编辑,更新,取消,删除,排序
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Bind();
}
//绑定
public void Bind()
{
ViewState["SortOrder"] = "Id";
ViewState["OrderDire"] = "asc";//这两句话是为了 排序绑定引用实例 先赋值
ddg.BLL.FenLei bfenlei = new ddg.BLL.FenLei();
DataSet ds = new DataSet();
ds = bfenlei.GetAllList();
gvwFenLei.DataSource = ds;
gvwFenLei.DataKeyNames = new string[] { "Id" };//设置主键字段
gvwFenLei.DataBind();
}
//删除
protected void gvwFenLei_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
ddg.Model.FenLei mfenlei = new ddg.Model.FenLei();
ddg.BLL.FenLei bfeilei = new ddg.BLL.FenLei();
mfenlei = bfeilei.GetModel(int.Parse(gvwFenLei.DataKeys[e.RowIndex].Value.ToString()));<