public void databinding(string key) { searching s = new searching(); SqlDataAdapter adapter = s.search(key); SqlCommandBuilder builder = new SqlCommandBuilder(adapter); DataSet ds = new DataSet(); adapter.Fill(ds, "Books"); ds.Tables["Books"].PrimaryKey = new DataColumn[] { ds.Tables["Books"].Columns["BID"] }; result_grid.DataSource = ds.Tables["Books"]; result_grid.DataBind(); }
protected void Search_btn_Click(object sender, EventArgs e) { string key = this.search_box.Text.ToString(); searching s = new searching(); SqlDataAdapter adapter = s.search(key); SqlCommandBuilder builder = new SqlCommandBuilder(adapter); DataSet ds = new DataSet(); //adapter.Fill(ds, "Books"); adapter.Fill(ds, "Books"); ds.Tables["Books"].PrimaryKey = new DataColumn[] { ds.Tables["Books"].Columns["BID"] }; result_grid.DataSource = ds.Tables["Books"]; result_grid.DataBind(); }