1. public ActionResult chartofaccountscreate()  
  2.        {  
  3.            // ViewBag.accountname = new SelectList(mse.chartofaccounts, "AccountName", "AccountName");  
  4.            treeviewlist();  
  5.            return View();  
  6.        }  
  7.   
  8.        [HttpPost]  
  9.        public ActionResult chartofaccountspost(FormCollection col)  
  10.        {  
  11.            chartofaccount coa = new chartofaccount();  
  12.            UpdateModel(coa);  
  13.            treeviewlist();  
  14.            if (ModelState.IsValid)  
  15.            {  
  16.                mse.chartofaccounts.Add(coa);  
  17.                mse.SaveChanges();  
  18.            }  
  19.            return View("chartofaccountscreate");  
  20.        }  
  21.   
  22.        public void treeviewlist()  
  23.        {  
  24.            List all = new List();  
  25.            using (mastersEntities dc = new mastersEntities())  
  26.            {  
  27.                all = dc.chartofaccounts.OrderBy(a => a.AccountName).ToList();  
  28.            }  
  29.            ViewBag.accountname = all;  
  30.        }  
  31.        public ActionResult chartofaccountedit(String name)  
  32.        {  
  33.            treeviewlist();  
  34.            chartofaccount data=null;  
  35.            if (name == null) {  
  36.   
  37.                
  38.                return View("chartofaccountscreate");  
  39.            }  
  40.            else  
  41.            {  
  42.                  
  43.               data = mse.chartofaccounts.SingleOrDefault(x => x.AccountName == name);  
  44.                int aid=data.ID;  
  45.   
  46.                return View("chartofaccountscreate", data);  
  47.            }  
  48.   
  49.        }