protected void Unnamed_Click(object sender, EventArgs e) { using (SMEntities context = new SMEntities()) { context.PERSONNELCATALOGs.ToList(); PERSONNELCATALOG pc = new PERSONNELCATALOG(); //pc.DepartmentID=txtBox1.text; context.PERSONNELCATALOGs.Add(pc); context.SaveChanges(); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { TableCell cell = GridView1.Rows[e.RowIndex].Cells[1]; using (SMEntities db = new SMEntities()) { var personToDelete = db.PERSONNELCATALOGs.Find(Convert.ToInt32(cell.Text)); if (personToDelete != null) { db.PERSONNELCATALOGs.Remove(personToDelete); db.SaveChanges(); GridView1.DataBind(); Response.Redirect("List.aspx"); } } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { //GridView gv = (GridView)sender; //GridViewRow gvr = (GridViewRow)gv.Rows[e.RowIndex]; // PERSONNELCATALOG pc = new PERSONNELCATALOG(); //// pc.Name = e.NewValues["Name"].ToString(); using (var context = new SMEntities()) { //int gvr = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[1].ToString()); // int str = Convert.ToInt32(e.NewValues["RegisterID"].ToString()); var cust = (from c in context.PERSONNELCATALOGs where c.RegisterID == 7 select c).First(); cust.Name = "Orhan"; context.SaveChanges(); GridView1.DataBind(); Response.Redirect("List.aspx"); } }