zoukankan      html  css  js  c++  java
  • AspNetPager操作示例1 枫

    /// <summary>
        /// 用Sql语句填充GridView
        /// <param name="SQLStr">用户SQL语句</param>
        /// <param name="TableName">主表数据表名称</param>
        /// <param name="myGrid">目标GridView ID</param>
        /// <param name="myPager">目标AspNetPager ID</param>
        /// <param name="myPageSize">每页显示的记录数</param>
        /// <param name="ShowText">是否显示记录总数、页数信息</param>
        /// </summary>

    public void BindGrid(string SQLStr, string TableName, Repeater myGrid, Wuqi.Webdiyer.AspNetPager myPager, int myPageSize, bool ShowText)
        {
            #region 绑定数据
            SqlDataAdapter da = new SqlDataAdapter(SQLStr, GetSQLConn());
            DataSet ds = new DataSet();
            myPager.PageSize = myPageSize;
            da.Fill(ds, myPager.PageSize * (myPager.CurrentPageIndex - 1), myPager.PageSize, TableName);
            myPager.AlwaysShow = true;
            myGrid.DataSource = ds;
            myGrid.DataBind();
            #endregion
        }

    ///////////////////

    <asp:DataList ID="gvNewsList" runat="server" RepeatColumns="3"
                        RepeatDirection="Horizontal" Width="100%">
                        <ItemTemplate>
                            <table border="0" align="center" cellpadding="0" cellspacing="0">
                                <tr>
                                  <td align="center"><a href="UpdateFile/<%#Eval("img") %>" target="_blank"><img src="UpdateFile/<%#Eval("img") %>" width="219" height="164" border="0" class="bkh" /></a></td>
                                </tr>
                                <tr>
                                  <td align="center" class="hei12"><a href="Orther.aspx?id=<%#Eval("id") %>" class="hl12"><%#Eval("title") %></a></td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:DataList>

    <webdiyer:AspNetPager ID="PostPager" runat="server" CustomInfoTextAlign="Right" Font-Names="宋体"
                                        HorizontalAlign="Left"
                         OnPageChanging="PostPager_PageChanging" PageSize="11"
                                        ShowBoxThreshold="2" ShowCustomInfoSection="Right" UrlPaging="True"
                                        Width="100%"
                                        FirstPageText="First" LastPageText="Last" NextPageText="Next"
                                        PageIndexBoxType="DropDownList" PrevPageText="Prev" ShowPageIndexBox="Always"
                                        SubmitButtonText="Go" TextAfterPageIndexBox="Page"
                                        TextBeforePageIndexBox="Go" ShowPageIndex="False"
                         CssClass="hl12"></webdiyer:AspNetPager>

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string type = "1";
                try
                {
                    type = Request.QueryString["type"].ToString();
                }
                catch
                {
                }

                GridBind(type);
            }
        }

     protected void GridBind(string type)
        {
            lblTempID.Text = type;
            string SQLStr = "SELECT * FROM Orther WHERE (type = '" + type + "') AND (lei = '1') ORDER BY id DESC";

            DataTable dt = cls.GetDataTable(SQLStr);

            if (dt.Rows.Count > 0)
            {
                PostPager.RecordCount = dt.Rows.Count;
                cls.BindGrid(SQLStr, "netNews", gvNewsList, PostPager, 12, true);
            }
            else
            {
                lblMessage.Visible = true;
                PostPager.Visible = false;
                gvNewsList.Visible = false;
            }

            dt.Dispose();
        }
        protected void PostPager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            PostPager.CurrentPageIndex = e.NewPageIndex;
            GridBind(lblTempID.Text);
        }

  • 相关阅读:
    你的面向对象技术在哪个级别?
    图解面向对象中的聚合与耦合概念
    系统架构39问
    谈谈对一些软件架构设计箴言的理解
    mysql 常用见的错误处理
    mysql 局域网连接
    mysql版本:'for the right syntax to use near 'identified by 'password' with grant option'
    Ubuntu系统开放指定端口
    spring cloud 项目
    spring cloud 知识总结
  • 原文地址:https://www.cnblogs.com/mrray/p/1885512.html
Copyright © 2011-2022 走看看