BookList.aspx.cs
上传用户:gooyliu
上传日期:2018-09-29
资源大小:5816k
文件大小:2k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. using System.Xml.Linq;
  13. using Model;
  14. using BusinessLogicLayer;
  15. namespace Web.SysAdmin
  16. {
  17.     public partial class BookList : System.Web.UI.Page
  18.     {
  19.         protected void Page_Load(object sender, EventArgs e)
  20.         {
  21.             if (!IsPostBack)
  22.             {
  23.                 BindBookList();
  24.             }
  25.         }
  26.         public void BindBookList()
  27.         {
  28.             BLLBook book = new BLLBook();
  29.             DataSet dsBooks = book.QueryBooks();
  30.             GridviewBookList.DataSource = dsBooks;
  31.             GridviewBookList.DataBind();     
  32.             
  33.             //dsBooks.WriteXml(Server.MapPath("test.xml"),XmlWriteMode.WriteSchema);
  34.         }
  35.  
  36.         protected void GridviewBookList_RowDeleting(object sender, GridViewDeleteEventArgs e)
  37.         {
  38.             string bookID = GridviewBookList.DataKeys[e.RowIndex].Values[0].ToString();
  39.             BLLBook book = new BLLBook();
  40.             if (book.DeleteByProc(bookID))
  41.                 Response.Write("<script language=javascript> alert('删除成功!')</script>");
  42.             else
  43.                 Response.Write("<script language=javascript> alert('删除失败!')</script>");
  44.             GridviewBookList.EditIndex = -1;
  45.             BindBookList();
  46.         }
  47.     }
  48. }