Пример #1
0
        protected void btnProducts_Click(object sender, EventArgs e)
        {
            //string connectionString = ConfigurationManager.ConnectionStrings["SalesConn"].ConnectionString;

            //using (SqlConnection cn = new SqlConnection(connectionString))
            //{
            //    SqlCommand cmd = new SqlCommand("select * from Products", cn);

            //    cn.Open();
            //    SqlDataReader reader = cmd.ExecuteReader();

            //    StringBuilder s = new StringBuilder();
            //    s.Append(@"<table class=""table"">");
            //    while (reader.Read())
            //    {
            //        s.Append(string.Format("<tr><td>{0}</td><td>{1}</td><td>{2:c}</td></tr>", reader["ProductId"],reader["ProductName"], reader["ProductPrice"]));
            //    }
            //    s.Append("</table>");
            //    LtrProducts.Text = s.ToString();
            //    cn.Close();
            //}

            DataTable dt = getProducts();

            GdvProducts.DataSource = dt;
            GdvProducts.DataBind();
        }
Пример #2
0
        protected void btnGridView_Click(object sender, EventArgs e)
        {
            LblTime.Text  = DateTime.Now.ToString();
            LblTime1.Text = DateTime.Now.ToString();
            DataTable dt = getProducts();

            GdvProducts.DataSource = dt;
            GdvProducts.DataBind();
        }
Пример #3
0
        protected void GdvProducts_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            LblTime.Text          = DateTime.Now.ToString();
            LblTime1.Text         = DateTime.Now.ToString();
            GdvProducts.PageIndex = e.NewPageIndex;

            DataTable dt = getProducts();

            GdvProducts.DataSource = dt;
            GdvProducts.DataBind();
        }