Exemple #1
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {

        List<Book> list = new List<Book>();

        String keyword = txtKeyword.Text;
        String type = SearchCondition_ddl.Text;
        if (type == "Title")
        {
            list = sc.searchByTitle(keyword);
        }
        else if (type == "Author")
        {
            list = sc.searchByAuthor(keyword);
        }

        try
        {
            this.GridView1.DataSource = list;
            this.GridView1.DataBind();
        }   catch (Exception ex)
        {
            string errormsg = string.Format("<script>Error:{0}</script>", ex.Message);
            Response.Write(errormsg);
        }
    }