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 BrandList", conn);
                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    ViewState["Paging"] = dt;
                    //BrandGridView.DataSource = null;
                    BrandGridView.DataSource = dt;
                    BrandGridView.DataBind();
                    ViewState["dirState"] = dt;
                    ViewState["sortdr"]   = "Asc";
                }
                else
                {
                    BrandGridView.DataSource = dt;
                    BrandGridView.DataBind();

                    ErrorLbl.Text   = "No records found...!!!";
                    successLbl.Text = "";
                }

                conn.Close();
            }
        }
Ejemplo n.º 2
0
        protected void BrandGridView_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";
                }
                BrandGridView.DataSource = dt;
                BrandGridView.DataBind();
            }
        }
Ejemplo n.º 3
0
 protected void BrandGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     BrandGridView.PageIndex  = e.NewPageIndex;
     BrandGridView.DataSource = ViewState["Paging"];
     BrandGridView.DataBind();
 }