protected void Button1_Click(object sender, EventArgs e) { var rand = new Random(); var Aufgabe = new MyToDos() { Bezeichnung = TextBox1.Text, Datum = DateTime.Now.AddSeconds(rand.Next(31536000)) }; var db = new DbTodo(); db.MyToDos.Add(Aufgabe); db.SaveChanges(); DataBind(); }
protected void TodoListView_ItemCommand(object source, ListViewCommandEventArgs e) { switch (e.CommandName) { case "del": var id = e.CommandArgument; //sql delete var db = new DbTodo(); db.MyToDos.Remove(db.MyToDos.Find(id)); //var del = new MyToDos() { Id = (int)id }; //db.MyToDos.Remove(del); db.SaveChanges(); break; default: break; } }