Beispiel #1
0
        public void PopulateGridView()
        {
            DataTable dt = new DataTable();
            //using (SqlConnection conn = new SqlConnection(ConnectionString))

            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PharmacyConnectionString"].ConnectionString);
            {
                conn.Open();
                SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM SuppliersList", conn);
                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    ViewState["Paging"] = dt;
                    //MedicineGridView.DataSource = null;
                    SuppliersGridView.DataSource = dt;
                    SuppliersGridView.DataBind();
                    ViewState["dirState"] = dt;
                    ViewState["sortdr"]   = "Asc";
                }

                if (dt.Rows.Count <= 0)
                {
                    //ErrorLbl.Text = "No Records Found....!!";
                    //successLbl.Visible = false;
                    SuppliersGridView.DataBind();
                    ErrorLbl.Text = "No Records Found....!!";
                }

                conn.Close();
            }
        }
Beispiel #2
0
        protected void SuppliersGridView_Sorting(object sender, GridViewSortEventArgs e)
        {
            DataTable dt = (DataTable)ViewState["dirState"];

            if (dt.Rows.Count > 0)
            {
                if (Convert.ToString(ViewState["sortdr"]) == "Asc")
                {
                    dt.DefaultView.Sort = e.SortExpression;
                    ViewState["sortdr"] = "Desc";
                }
                else
                {
                    dt.DefaultView.Sort = e.SortExpression;
                    ViewState["sortdr"] = "Asc";
                }
                SuppliersGridView.DataSource = dt;
                SuppliersGridView.DataBind();
            }
        }
Beispiel #3
0
 protected void SuppliersearchTextBox_TextChanged(object sender, EventArgs e)
 {
     if (SuppliersearchTextBox.Text == "")
     {
         PopulateGridView();
     }
     else
     {
         SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PharmacyConnectionString"].ConnectionString);
         DataTable     dt   = new DataTable();
         conn.Open();
         SqlCommand command = new SqlCommand("searchsuppliers", conn);
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@name", SuppliersearchTextBox.Text);
         SqlDataAdapter adapter = new SqlDataAdapter(command);
         adapter.Fill(dt);
         SuppliersGridView.DataSource = dt;
         SuppliersGridView.DataBind();
     }
 }
Beispiel #4
0
 public void LoadSuppliers()
 {
     SuppliersGridView.DataSource = _SupplierRepository.GetAllSupplliers();
     SuppliersGridView.DataBind();
 }
Beispiel #5
0
 protected void SuppliersGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     SuppliersGridView.PageIndex  = e.NewPageIndex;
     SuppliersGridView.DataSource = ViewState["Paging"];
     SuppliersGridView.DataBind();
 }