protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { List<Book> l_BookList = new List<Book>(); l_BookList = sc.selectAll(); this.GridView1.DataSource = l_BookList; this.GridView1.DataBind(); } catch (Exception ex) { string errormsg = string.Format("<script>Error:{0}</script>", ex.Message); Response.Write(errormsg); } } }