protected override void AddPrivate(Database db) { ProjectsTableAdapter tableAdapter = db.ProjectsTableAdapter; tableAdapter.Insert(name, description, displayOrder, (int)state); // Find ID. ID = tableAdapter.Connection.GetInsertedIdentity(); }
protected void InsertButton_Click(object sender, EventArgs e) { DeptsTableAdapter dta = new DeptsTableAdapter(); DropDownList dept = FormView1.FindControl("Dept") as DropDownList; var d = dta.GetDeptByDescription(dept.Text); GroupsTableAdapter gta = new GroupsTableAdapter(); DropDownList group = FormView1.FindControl("Group") as DropDownList; var g = gta.GetGroupByName(group.Text); ProjectsTableAdapter ta = new ProjectsTableAdapter(); TextBox tb = FormView1.FindControl("NameTextBox") as TextBox; CheckBox cb = FormView1.FindControl("ActiveCheckBox") as CheckBox; ta.Insert(Guid.NewGuid(), tb.Text, cb.Checked, d[0].Id, g[0].Id); GoBack(); }