您目前尚未登陆,请选择【登陆】或【注册
首页->功能源码->Linq三层模式之增删改源码>>Default.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Linq三层模式之增删改源码
当前文件:文件类型 LinqDemo/Default.aspx.cs打开代码结构图
高亮显示
		            using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
//Download from 51aspx.com/cv/LinqDemo
public partial class _Default : System.Web.UI.Page 
{

    StaffBLL sb = new StaffBLL();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            bindData();
        }
    }

    private void bindData()
    {
        //StaffBLL sb = new StaffBLL();
        this.GridView1.DataSource = sb.LinqStaff();
        this.GridView1.DataBind();
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        this.GridView1.EditIndex = e.NewEditIndex;
        bindData();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int id = Convert.ToInt32(this.GridView1.DataKeys[e.RowIndex].Value);
        TextBox staffTb = this.GridView1.Rows[e.RowIndex].Cells[1].Controls[0] as TextBox;
        TextBox ageTb = this.GridView1.Rows[e.RowIndex].Cells[2].Controls[0] as TextBox;
        string staffName = staffTb.Text;
        int  age = Convert.ToInt32(ageTb.Text);
        sb.LinqUpdateStaff(id, staffName, age);
        this.GridView1.EditIndex = -1;
        bindData();
    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        this.GridView1.EditIndex = -1;
        bindData();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        sb.LinqInsertStaff(this.TextBox1.Text,Convert.ToInt32(this.TextBox2.Text));
        bindData();
        this.TextBox1.Text = "";

    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int id = Convert.ToInt32(this.GridView1.DataKeys[e.RowIndex].Value);
        sb.LinqDeleteStaff(id);
        bindData();
    }
}


        
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:Linq三层模式之增删改源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号