protected void Page_Load(object sender, EventArgs e) { using (Entities db = new Entities()) { LendingManager lenMan = new LendingManager(db); List<LendingInfo> lendings = lenMan.GetLendings(); if (lendings.Count == 0) { Button1.Visible = false; } GridView1.DataSource = lendings; GridView1.DataBind(); } }
protected void Return_Click(object sender, EventArgs e) { using (Entities db = new Entities()) { LendingManager lenMan = new LendingManager(db); List<LendingInfo> lendings = (List<LendingInfo>)GridView1.DataSource; lenMan.ReturnBook(lendings[GridView1.SelectedIndex].LendId); lendings = lenMan.GetLendings(); if (lendings.Count == 0) { Button1.Visible = false; } GridView1.DataSource = lendings; GridView1.DataBind(); } }