打印本文 打印本文 关闭窗口 关闭窗口
ASP.NET分页组件学与用——使用篇
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1563  更新时间:2009/4/23 10:41:50  文章录入:mintao  责任编辑:mintao
 大家好,这篇文章承启上一篇文章《ASP.NET分页组件学与用——教学篇》。

 

       在《ASP.NET分页组件学与用——教学篇》中,我们讲解了分页组件的整个创建过程,那么在这一篇文章中,我们主要讨论一下如何使用该组件。

 

       请按以下步骤操作:

1、  创建一个WEB应用程序工程。

 

2、  将上篇文章中生成的组件添加到工具箱中。如果您不知道添加的过程,请参考文章《ASP.NET组件编程step by step》

 

 

3、  在默认的WEB窗体页面中,切换到HTML视图,把下列HTML代码复制到<form>标签中。

<div align="center">

                            <center>

                                   <table border="0" cellpadding="0" cellspacing="0" width="756" height="155" style="FONT-SIZE:12px">

                                          <tr>

                                                 <td width="756" height="23">分页控件的使用实例</td>

                                          </tr>

                                          <tr>

                                                 <td width="756" height="110" valign="top" align="center" runat="server" id="myHtml"></td>

                                          </tr>

                                          <tr>

                                                 <td width="756" height="22">

                                                 </td>

                                          </tr>

                                   </table>

                            </center>

                     </div>

 

4、  该HTML代码生成一个三行一列的表格,从工具箱将控件拖到该表格的第三行中。

 

5、  在private void Page_Load(object sender, System.EventArgs e)事件处理程序中添加如下代码:

int cp;

            if(this.Request.Params["currentPage"] == null)

            {

                cp = 1;

            }

            else

            {

                cp = Convert.ToInt32(this.Request.Params["currentPage"]);

            }

 

            SqlConnection con = new SqlConnection("server=accp-lzh;uid=sa;pwd=sasa;database=Northwind");

            SqlCommand cmd = new SqlCommand("select * from [Order Details]",con);

            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.SelectCommand = cmd;

   

[1] [2]  下一页

打印本文 打印本文 关闭窗口 关闭窗口