Tuesday, 3 January 2012

Creating an ADO.NET Entity Framework Entity Data Model (using procedure)part-2

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DatabaseModel;

public partial class _Default : System.Web.UI.Page
{
#region
DatabaseEntities o = new DatabaseEntities();
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
view();
}
void view()
{
gv.DataSource = o.EMPs;
gv.DataBind();
}
protected void btn_Click(object sender, EventArgs e)
{
o.EMP1(Convert.ToInt32(tb.Text), tb1.Text);
view();
}
protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gv.PageIndex = e.NewPageIndex;
view();
}
protected void gv_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gv.EditIndex = -1;
view();
}
protected void gv_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

o.EMP3(Convert.ToInt32(gv.DataKeys[e.RowIndex].Value));
view();
}
protected void gv_RowEditing(object sender, GridViewEditEventArgs e)
{
gv.EditIndex = e.NewEditIndex;
view();
}
protected void gv_RowUpdating(object sender, GridViewUpdateEventArgs e)
{

o.EMP2(Convert.ToInt32(gv.DataKeys[e.RowIndex].Value),((TextBox)gv.Rows[e.RowIndex].Cells[3].Controls[0]).Text);
gv.EditIndex = -1;
view();
}
}

No comments:

Post a Comment