在做一个网页的时候,出去版面的问题,必须要用到DATALIST
datagrid版面太死了,但是datalist又没有分页功能,希望有人指点
最好是提供一个控件,有VB.NET说明其接口或者相信的用法

解决方案 »

  1.   

    datalist 可以实现分页的呀
      

  2.   

    <td align="center">共有
    <asp:label id="lblRecordCount" runat="server" ForeColor="red"></asp:label>條記錄&nbsp; 
    當前為
    <asp:label id="lblCurrentPage" runat="server" ForeColor="red"></asp:label>/
    <asp:label id="lblPageCount" runat="server" ForeColor="red"></asp:label>頁
    <asp:HyperLink id="lnkPrev" runat="server">上一頁</asp:HyperLink>
    <asp:HyperLink id="lnkNext" runat="server">下一頁</asp:HyperLink>
    -------------------------------------------------------------------------------
    public void BindGrid() 
    {
    // 在此处放置用户代码以初始化页面
    if(!Page.IsPostBack)
    {
    int BID,SID;
    if ((Request.QueryString["BID"]==null)||(Request.QueryString["SID"]==null))
    {
    BID=1;
    SID=200;
    }
    else
    {
    BID=System.Convert.ToInt32(Request.QueryString["BID"]);
    SID=System.Convert.ToInt32(Request.QueryString["SID"]);
    }                             PageSize=System.Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["MainList"]);
    CurrentPage = 0;
    //计算总共有多少记录
                                   string str1,str2;
                                   str1="SELECT  COUNT(*)  as co from pur where P_ID<>'' ";
                                   str2="select *,pono as pono2 from pur where P_ID<>'' ";
                     
    int RecordCount = DBOperate.CalculateQRecord(BID, SID,str1);
    lblRecordCount.Text = RecordCount.ToString();
    //计算总共有多少页
    PageCount = (RecordCount+PageSize-1)/PageSize;
    if (PageCount<=0)
    PageCount=1;
    lblPageCount.Text = PageCount.ToString();
    //获取页面参数
    if (Request.QueryString["Page"] != null)
    CurrentPage=Convert.ToInt32(Request.QueryString["Page"]);
    else
    CurrentPage=1;
    if (PageCount<CurrentPage)
    CurrentPage=PageCount;
    if (CurrentPage<=0)
    CurrentPage=1; //ListBind();
    //设定导入的起终地址
    int StartIndex = (CurrentPage-1)*PageSize;
                     string tablestr="pur";
    //this.DL_Main.DataSource= DBOperate.SelectFormForum(str2,StartIndex,PageSize,tablestr);
                               DataTable dt=DBOperate.SelectFormForum(str2,StartIndex,PageSize,tablestr);
                               this.DL_Main.DataSource=dt;
    this.Page.DataBind();
    lnkNext.Enabled = true;
    lnkPrev.Enabled = true;
    if(CurrentPage==(PageCount))
    {
    lnkNext.Enabled = false;
    }
    else
    lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+ "?BID="+ BID.ToString()+"&SID="+ SID.ToString()+"&Page="+Convert.ToString(CurrentPage+1);
    if(CurrentPage==1)
    lnkPrev.Enabled = false;
    else
    lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath + "?BID="+ BID.ToString()+"&SID="+ SID.ToString()+"&Page="+Convert.ToString(CurrentPage-1);
    lblCurrentPage.Text = CurrentPage.ToString(); }
    }