private void BindGrid() { DataTable dt = new DataTable(); DataSet ds = new DataSet(); #region Getting Product Details try { string Text = UserName.Text; String Query = "SELECT * From tbl_Users Where [tbl_Users].U_EmpID LIKE '" + Text + "'"; connection.Open(); SqlCommand command = new SqlCommand(Query, connection); SqlDataAdapter SA = new SqlDataAdapter(command); UserSet = null; SA.Fill(ds); UserSet = ds; SalemanDisplayGrid.DataSource = ds; SalemanDisplayGrid.DataBind(); } catch (Exception ex) { } finally { connection.Close(); } #endregion }
protected void btnSearch_Click(object sender, EventArgs e) { try { connection.Open(); string Text = UserName.Text; // String Text = SelectProduct.SelectedItem.ToString() + "%"; SqlCommand command = new SqlCommand("SELECT * From tbl_Users Where [tbl_Users].U_EmpID LIKE '" + Text + "'", connection); DataSet ds = new DataSet(); SqlDataAdapter sA = new SqlDataAdapter(command); sA.Fill(ds); //if (SelectProduct.DataSource != null) //{ // SelectProduct.DataSource = null; //} UserSet = null; UserSet = ds; SalemanDisplayGrid.DataSource = ds; SalemanDisplayGrid.DataBind(); } catch (Exception ex) { } finally { connection.Close(); } }