Ejemplo n.º 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 MedicineList", conn);
                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    ViewState["Paging"] = dt;
                    //MedicineGridView.DataSource = null;
                    MedicineGridView.DataSource = dt;
                    MedicineGridView.DataBind();
                    ViewState["dirState"] = dt;
                    ViewState["sortdr"]   = "Asc";
                }
                else
                {
                    MedicineGridView.DataSource = dt;
                    MedicineGridView.DataBind();
                    ErrorLbl.Text = "No records found...!!!";
                }

                conn.Close();
            }
        }
Ejemplo n.º 2
0
        protected void MedicineGridView_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";
                }
                MedicineGridView.DataSource = dt;
                MedicineGridView.DataBind();
            }
        }
Ejemplo n.º 3
0
 protected void itemsearchTextBox_TextChanged(object sender, EventArgs e)
 {
     if (itemsearchTextBox.Text == "")
     {
         PopulateGridView();
     }
     else
     {
         SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PharmacyConnectionString"].ConnectionString);
         DataTable     dt   = new DataTable();
         conn.Open();
         SqlCommand command = new SqlCommand("search2", conn);
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@name", itemsearchTextBox.Text);
         SqlDataAdapter adapter = new SqlDataAdapter(command);
         adapter.Fill(dt);
         MedicineGridView.DataSource = dt;
         MedicineGridView.DataBind();
     }
 }
        public void LoadDataGridView()
        {
            MedicineList = aHeadOfficeManager.GetMedicineList();

            if (dt.Columns.Count == 0)
            {
                dt.Columns.Add("Serial No", typeof(string));
                dt.Columns.Add("Medicine Name", typeof(string));
            }
            int count = 1;

            foreach (var Medicine in MedicineList)
            {
                DataRow NewRow = dt.NewRow();
                NewRow[0] = count.ToString();

                NewRow[1] = Medicine.MedicineName;
                dt.Rows.Add(NewRow);
                count++;
            }
            MedicineGridView.DataSource = dt;
            MedicineGridView.DataBind();
        }
Ejemplo n.º 5
0
 protected void MedicineGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     MedicineGridView.PageIndex  = e.NewPageIndex;
     MedicineGridView.DataSource = ViewState["Paging"];
     MedicineGridView.DataBind();
 }