• asp.net gridview实现正在加载效果方案一AJAX(转)


    前台代码:

    <%@ 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">
    <head runat="server">
        <title></title>
      
    </head>
    <body>
         <form id="form1" runat="server">
        <div>

            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <fieldset>
                    <legend>UpdatePanel</legend>
                    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
                    <asp:UpdateProgress ID="UpdateProgress1" runat="server"> 
            <ProgressTemplate> 
            正在加载数据............. 
            </ProgressTemplate> 
            </asp:UpdateProgress> 
                    <asp:GridView ID="GridView1" runat="server" 
                onrowcreated="GridView1_RowCreated" 
                onpageindexchanging="GridView1_PageIndexChanging" Width="1000px"
             onrowdatabound="GridView1_RowDataBound"
                 EmptyDataText="没有查询到您所需要的数据" PageSize="15" AllowPaging="True" >
                    <FooterStyle CssClass="GridViewFooterStyle" />
                    <RowStyle CssClass="GridViewRowStyle" />  
                    <SelectedRowStyle CssClass="GridViewSelectedRowStyle" />
                   <PagerStyle CssClass="GridViewPagerStyle" />
        <AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" />
        <HeaderStyle CssClass="GridViewHeaderStyle" />

            </asp:GridView>
                    </fieldset>
                </ContentTemplate>
            </asp:UpdatePanel>

        </div>
        </form>
    </body>
    </html>

    后台cs代码:

    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();
        }
    }
  • 相关阅读:
    2015 HUAS Summer Contest#2~B
    2015 HUAS Summer Contest#2~A
    HUAS Summer Trainning #3~B
    HUAS Summer Trainning #3~A
    2015 HUAS Provincial Select Contest #1~D
    UVA 725
    货币体系
    N皇后摆放问题
    种子填充找连通块 floodfill
    二叉树的递归遍历,用先序和中序输出后序
  • 原文地址:https://www.cnblogs.com/hfzsjz/p/3230271.html
Copyright © 2020-2023  润新知