// The return type can be changed to IEnumerable, however to support // paging and sorting, the following parameters must be added: // int maximumRows // int startRowIndex // out int totalRowCount // string sortByExpression public IQueryable <supplier> GridView1_GetData() { SupplierDBModel context = new SupplierDBModel(); return((from s in context.suppliers select s).AsQueryable()); }
//use object of type customer to get value from formview // the value will be bound to customer automaticlly // or you can use the method TryUpdateMedel to populate your model public void FormView1_InsertItem(supplier supplier) { using (SupplierDBModel context = new SupplierDBModel()) { //Customer customer=new Customer() //TryUpdateModel(customer) if (ModelState.IsValid) { supplier.webstatus = "Invited To Portal"; context.suppliers.Add(supplier); context.SaveChanges(); } } }
// The id parameter name should match the DataKeyNames value set on the control public void GridView1_UpdateItem(int supplierid) { using (SupplierDBModel context = new SupplierDBModel()) { PrincePortalWeb.Models.supplier item = null; item = context.suppliers.Find(supplierid); // Load the item here, e.g. item = MyDataLayer.Find(id); if (item == null) { // The item wasn't found ModelState.AddModelError("", String.Format("Item with id {0} was not found", supplierid)); return; } TryUpdateModel(item); if (ModelState.IsValid) { context.SaveChanges(); } } }