您目前尚未登陆,请选择【登陆】或【注册
首页->功能源码->Linq三层模式之增删改源码>>Default.aspx.cs>>代码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:Linq三层模式之增删改源码


当前文件路径:LinqDemo/Default.aspx.cs 文件类型
普通视图
		            
1using System; 2using System.Configuration; 3using System.Data; 4using System.Linq; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.HtmlControls; 9using System.Web.UI.WebControls; 10using System.Web.UI.WebControls.WebParts; 11using System.Xml.Linq; 12//Download from 51aspx.com/cv/LinqDemo 13public partial class _Default : System.Web.UI.Page 14{ 15 16 StaffBLL sb = new StaffBLL(); 17 protected void Page_Load(object sender, EventArgs e) 18 { 19 if (!this.IsPostBack) 20 { 21 bindData(); 22 } 23 } 24 25 private void bindData() 26 { 27 //StaffBLL sb = new StaffBLL(); 28 this.GridView1.DataSource = sb.LinqStaff(); 29 this.GridView1.DataBind(); 30 } 31 protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) 32 { 33 this.GridView1.EditIndex = e.NewEditIndex; 34 bindData(); 35 } 36 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) 37 { 38 int id = Convert.ToInt32(this.GridView1.DataKeys[e.RowIndex].Value); 39 TextBox staffTb = this.GridView1.Rows[e.RowIndex].Cells[1].Controls[0] as TextBox; 40 TextBox ageTb = this.GridView1.Rows[e.RowIndex].Cells[2].Controls[0] as TextBox; 41 string staffName = staffTb.Text; 42 int age = Convert.ToInt32(ageTb.Text); 43 sb.LinqUpdateStaff(id, staffName, age); 44 this.GridView1.EditIndex = -1; 45 bindData(); 46 } 47 protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) 48 { 49 this.GridView1.EditIndex = -1; 50 bindData(); 51 } 52 protected void Button1_Click(object sender, EventArgs e) 53 { 54 sb.LinqInsertStaff(this.TextBox1.Text,Convert.ToInt32(this.TextBox2.Text)); 55 bindData(); 56 this.TextBox1.Text = ""; 57 58 } 59 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) 60 { 61 int id = Convert.ToInt32(this.GridView1.DataKeys[e.RowIndex].Value); 62 sb.LinqDeleteStaff(id); 63 bindData(); 64 } 65} 66
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:Linq三层模式之增删改源码

- 网站后台管理系统框架(精美..

- 简单新闻管理系统(Access数据..

- hww企业网站实用源码 V2.0

- 拖动的个性化网页布局源码(Ajax)

- JavaScript+Jquery+Ajax用户..

- 网络用户管理系统源码(面向对象)

- 功能很全asp.net图片水印组件..

- UrlReWrite(Url重写或伪静态..

51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号