GridView与UpdatePanel组合无刷新分页

转载 2007年09月28日 09:21:00

这个类子很简单,我把他放最前面。

拖这三控件,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>

OK。测试通过!

 

相关文章推荐

Repater无刷新分页(UpdatePanel)

前台代码如下://首先引用jquery.js文件 <asp:Scr

UpdatePanel GridView 无刷新操作

前台代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com...

Android自定义控件(一) 下拉刷新,上拉分页加载更多(支持ListView, GridView, ScrollView)

项目中用到了下拉刷新和上啦加载

Android自定义控件(二) 下拉刷新,上拉分页加载更多(支持ListView, GridView, ScrollView)

接着上一篇,进行代码分析,先贴上 :

下拉刷新+分页加载通用版本支持gridview、listview、scrollview

public class PullToRefreshView extends LinearLayout { private static final String TAG = "PullToRefr...

简单 GridView AJAX 局部刷新分页例子@孟宪会

@ Page Language="C#" %> @ Import Namespace="System.Data" %> @ Import Namespace="System.Data.Ol...
  • xk2y
  • xk2y
  • 2011-08-28 02:43
  • 835

AspNetPager分页 用法2及UpdatePanel异步分页

分页用法 AspNetPager属性如下: 1、ShowInputBox="Never"  不显示文本输入框        如果跳转不可以,则要加:UrlPaging="True" ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)