protected void Btn_Save_Click(object sender, EventArgs e) { DataEntities ent = new DataEntities(); int id = 0; try { id = Spe_Tree.SelectedNode.Value.ToInt32(0); } catch { } if (chk_Edit.Checked) { var q = (from l in ent.JobIndustry where l.ID == id select l).FirstOrDefault(); q.Name = txt_Name.Text; } else { JobIndustry spe = new JobIndustry(); spe.ParentID = id; spe.Name = txt_Name.Text; ent.AddToJobIndustry(spe); } ent.SaveChanges(); ent.Dispose(); Spe_Tree.Nodes.Clear(); LoadTree(); }