zoukankan      html  css  js  c++  java
  • GridView如何实现无刷新分页?

     

    拖这三控件,ScriptManager、UpdatePanel、GridView,其中GridView放在UpdatePanel里面。设置UpdatePanel的Triggers属性,分别绑定GridView的分页、删除、更新、编辑事件。OK。GridView怎么使用,我就不说了,不会的话去找找资料看看。如下:

    <Triggers>
         <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="PageIndexChanging" />
         <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="RowDeleting" />
         <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="RowUpdating" />
         <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="RowEditing" />
    </Triggers>

    所有代码如下:

    <asp:ScriptManager runat="server"   />

                 <asp:UpdatePanel runat="server">

                     <ContentTemplate>

                         <asp:SqlDataSource runat="server" ConnectionString="<%$ ConnectionStrings:AjaxDbConnectionString %>"

                             SelectCommand="SELECT [id], [namer], [title], [content] FROM [userid]"

                             DeleteCommand="DELETE FROM userid WHERE id=@id"

                             UpdateCommand="UPDATE userid SET [namer]=@namer,[title]=@title,[content]=@content WHERE id=@id">

                             <DeleteParameters>

                                 <asp:Parameter />

                             </DeleteParameters>

                             <UpdateParameters>

                                 <asp:Parameter />

                                 <asp:Parameter />

                                 <asp:Parameter />

                             </UpdateParameters>

                             </asp:SqlDataSource>

                         <asp:GridView runat="server" AllowPaging="True" AutoGenerateColumns="False"

                             BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"

                             CellPadding="3" DataKeyNames="id" DataSourceID="SqlDataSource1" PageSize="2">

                             <FooterStyle BackColor="White" ForeColor="#000066" />

                             <Columns>

                                 <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"

                                     SortExpression="id" />

                                 <asp:BoundField DataField="namer" HeaderText="namer" SortExpression="namer" />

                                 <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />

                                 <asp:BoundField DataField="content" HeaderText="content" SortExpression="content" />

                                 <asp:CommandField ShowDeleteButton="True" />

                                 <asp:CommandField ShowEditButton="True" />

                             </Columns>

                             <RowStyle ForeColor="#000066" />

                             <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />

                             <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />

                             <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />

                         </asp:GridView>

                     </ContentTemplate>

                     <Triggers>

                         <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="PageIndexChanging" />

                         <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="RowDeleting" />

                         <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="RowUpdating" />

                         <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="RowEditing" />

                     </Triggers>

                 </asp:UpdatePanel>

  • 相关阅读:
    [视频]K8飞刀--WinRAR远程代码执行漏洞利用视频
    [视频]K8飞刀 SQL注入点脱库演示教程
    [视频]K8飞刀 mysql注入点拿shell & UDF提权教程
    [视频]K8飞刀无代码编程之生成EXP
    [视频]K8飞刀 exploit管理功能 演示教程
    [视频]K8飞刀 Discuz! X 系列(1.5 2.5 3.x)产品升级漏洞GetShell教程
    [视频]K8飞刀 WordPress XSS添加管理员 & GetShell 教程
    [视频]K8飞刀 HackerIE自动检测网站注入教程
    [视频]K8飞刀 shellcode loader演示教程
    [视频]K8飞刀 ms15022 office漏洞演示动画
  • 原文地址:https://www.cnblogs.com/xryyforver/p/1508840.html
Copyright © 2011-2022 走看看