Asp.net gridview implements Scheme 1 of Loading results

Source: Internet
Author: User
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml"> 
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data.SqlClient;using System.Data;public partial class _Default : System.Web.UI.Page{           protected void Page_Load(object sender, EventArgs e)    {            }    protected void Button1_Click(object sender, EventArgs e)    {        System.Threading.Thread.Sleep(3000);        databind();    }    public void databind()    {        string sql = "SELECT [orderid], [customerid], [shipvia], [shipname] FROM [orders]";        string con = "Data Source=.;Initial Catalog=northwind;User ID=sa;Password=19790601";        SqlConnection mycon = new SqlConnection(con);        mycon.Open();        SqlDataAdapter mydt = new SqlDataAdapter(sql, mycon);        DataSet ds = new DataSet();        mydt.Fill(ds);        GridView1.DataSource = ds;        GridView1.DataBind();        mycon.Close();    }    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)    {        GridView1.PageIndex = e.NewPageIndex;        databind();    }}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.