protected void delete_book(object sender, EventArgs e)//删除单个书籍记录 { Button btn = (Button)sender; string id = btn.CommandArgument; int bookid = Int32.Parse(id); book_tableTableAdapter bookadpr = new book_tableTableAdapter(); locationTableAdapter locationadpr = new locationTableAdapter(); try { locationadpr.DeleteQuery(bookid); bookadpr.DeleteQuery(bookid); bookGridView.DataBind(); } catch { Label_delete_book.Text = "不能删除有借阅记录的书"; Label_delete_book.Visible = true; } }