• asp:ObjectDataSource+asp:GridView 实现真分页


     <asp:GridView
                ID="GridViewCacheManager"
                DataSourceID="OdsCacheManager"
                runat="server"
                Width="100%"
                CssClass="datable"
                border="0"
                CellPadding="4"
                OnRowDataBound="GridViewCacheManager_RowDataBound"
                OnRowCommand="GridViewCacheManager_RowCommand"
                AutoGenerateColumns="False"
                AllowPaging="True"
                PageSize="15"
                AllowSorting="True" EnableModelValidation="True" ForeColor="#333333" GridLines="None">
    
                <PagerSettings Visible="False" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Left" />
                <RowStyle CssClass="lupbai" BackColor="#EFF3FB" HorizontalAlign="Center" />
                <HeaderStyle CssClass="lup" BackColor="#b6c9e7" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#2461BF" />
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle CssClass="trnei" BackColor="White" />
                <Columns>
    
                    <asp:TemplateField  HeaderText="选择">
                        <HeaderStyle Width="40px" />
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
    
                    <asp:BoundField DataField="Title" HeaderText="标题">
                        <HeaderStyle Width="250px" />
                    </asp:BoundField>
    
                    <asp:BoundField DataField="Views" HeaderText="浏览">
                        <HeaderStyle Width="50px" />
                    </asp:BoundField>
    
                    <asp:BoundField DataField="Shares" HeaderText="收藏">
                        <HeaderStyle Width="50px" />
                    </asp:BoundField>
    
                    <asp:BoundField DataField="Status" HeaderText="状态">
                        <HeaderStyle Width="50px" />
                    </asp:BoundField>
    
                    
                    <asp:BoundField DataField="AddTime" HeaderText="发表时间" DataFormatString="{0:yyyy-MM-dd HH:mm}"  HtmlEncode="false">
                        <HeaderStyle Width="80px" />
                    </asp:BoundField>
    
                    <asp:BoundField DataField="EditTime" HeaderText="编辑时间" DataFormatString="{0:yyyy-MM-dd HH:mm}"  HtmlEncode="false">
                        <HeaderStyle Width="80px" />
                    </asp:BoundField>
                   
                    <asp:TemplateField HeaderText="常规操作">
                        <ItemTemplate>
                            <asp:LinkButton ID="lbtnview" runat="server" PostBackUrl="">查看</asp:LinkButton>
                        </ItemTemplate>
                        <HeaderStyle Width="120px" />
                    </asp:TemplateField>
    
                </Columns>
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            </asp:GridView>
    
            <asp:ObjectDataSource
                ID="OdsCacheManager"
                runat="server"
                SelectMethod="SelectAllToTable"
                TypeName="Data.ArticleDao"
                EnablePaging="false"
                StartRowIndexParameterName="startRowIndex"
                MaximumRowsParameterName="maxRows"
                SelectCountMethod="GetCount">
    
                <SelectParameters>
                    <%--<asp:ControlParameter Name="type" ControlID="hiddenFiledType" PropertyName="value" />
                    <asp:ControlParameter Name="userID" ControlID="hiddenFiledUserID" PropertyName="value" /> --%>
                </SelectParameters>
    
            </asp:ObjectDataSource>
    
            <asp:HiddenField ID="hiddenFiledUserID" runat="server" Value="0" />
            <asp:HiddenField ID="hiddenFiledType" runat="server" Value="1" />
    protected void GridViewCacheManager_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                int ID = Convert.ToInt32(e.CommandArgument);
                if (e.CommandName == "Del")
                {
                    // bool isSuccess = UserDao.DeleteUserByID(ID);
                }
            }
    
            protected void GridViewCacheManager_RowDataBound(object sender, GridViewRowEventArgs e)
            {
    
            }

            public static DataTable SelectAllToTable()
            {
              
                return result;
            }

  • 相关阅读:
    了解大数据的特点、来源与数据呈现方式
    结对项目
    第四次作业
    阅读《构建之法》1-5章有感
    iOS 应用如何完全支持 IPv6-ONLY 网络?
    丙申年把真假美猴王囚禁在容器中跑 ASP.NET Core 1.0
    ASP.NET Core 1.0 部署 HTTPS (.NET Framework 4.5.1)
    推荐一款跨平台的 Azure Storage Explorer
    更改 Skype for Business Online 的 Sip 地址以匹配UPN
    C# 计算字符串在控制台中的显示长度
  • 原文地址:https://www.cnblogs.com/maijin/p/4668326.html
Copyright © 2020-2023  润新知