| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1378 人关注过本帖
标题:js ajax分页的排版问题
只看楼主 加入收藏
等待冰柠檬
Rank: 2
来 自:浙江温州
等 级:论坛游民
帖 子:208
专家分:70
注 册:2008-6-25
结帖率:66.67%
收藏
 问题点数:0 回复次数:13 
js ajax分页的排版问题
图片附件: 游客没有浏览图片的权限,请 登录注册

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserGet.aspx.cs" Inherits="WzJyw.manager.UserGet" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.

<html xmlns="http://www. >
<head runat="server">
    <title>无标题页</title>
   <%-- <link rel="stylesheet" type="text/css" href="skin/css/main.css"> --%>
        <style type="text/css">
       .style1
        {
            width: 15%;
        }
        .style2
        {
            width: 20%;
        }
        .style3
        {
            width: 5%;
        }
        .style4
        {
            width: 10%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Repeater ID="Repeater1" runat="server">
    <HeaderTemplate>
    <table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px">
    <tr bgcolor="#E7E7E7">
        <td height="24" colspan="5" background="skin/images/tbg.gif"  align=center>&nbsp;会员列表&nbsp;</td>
    </tr>
    <tr bgcolor="#FAFAF1" height="22" align=center>
        <td class="style1">用户名</td>
        <td class="style1">密码</td>
        <td class="style3">类型</td>
        <td class="style1">注册时间</td>
        <td class="style4">操作</td>
    </tr>
    </table>
    </HeaderTemplate>
    <ItemTemplate>
   <table width="98%" border="0" cellpadding="2" cellspacing="1" align="center">
   <tr  align="center" bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22" >
    <td class="style1"><a href="DetailsManager.aspx?userid=<%#DataCommon.Users.GetUserid(Eval("YongHu").ToString())%>"><%#Eval("YongHu")%></a></td>
    <td class="style1"><%#Eval("Passwod")%></td>
    <td class="style3"><%#DataCommon.Users.Gettype(int.Parse(Eval("Type").ToString()))%></td>
    <td class="style1"><%#Eval("RegistDateTime")%></td>  
    <td class="style4">
    <a href="UserManager.aspx?id=<%#Eval("Id")%>">修改</a>
   <%-- <asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="return confirm('您确定删除吗')" CommandArgument='<%#Eval("Id")%>' OnClick="LinkButton1_Click">删除</asp:LinkButton>--%>
    </td>
    </tr>
    </table>
    </ItemTemplate>
    </asp:Repeater>
    </form>
</body>
</html>

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DataCommon;
using System.Data.SqlClient;
using System.Text;
using Common;

namespace WzJyw.manager
{
    public partial class UserGet : System.Web.UI.Page
    {
        string strConn = SqlHelper.ConnectionStringLocalTransaction;

        string s_CurrentPage = string.Empty;
        string s_PageCount = string.Empty;
        string s_RecordCount = string.Empty;

        int i_CurrentPage = 0;
        int i_PageCount = 0;
        int i_RecordCount = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["PageIndex"] != null)
            {
                if (!string.IsNullOrEmpty(Request.Params["PageIndex"]))
                {
                    s_CurrentPage = Request.Params["PageIndex"].ToString();
                    i_CurrentPage = Int32.Parse(s_CurrentPage);
                }
            }
            BindDateList();
        }
      void BindDateList()
      {
        string strSql_Count = "Select * from Users";
        s_RecordCount = SqlHelper.ExecuteDataTable(CommandType.Text,strSql_Count).Rows.Count.ToString();
        i_RecordCount = Convert.ToInt32(s_RecordCount);

        if (i_RecordCount % 4 > 0)
        {
            i_PageCount = i_RecordCount / 4 + 1;
        }
        else
        {
            i_PageCount = i_RecordCount / 4;
        }

        s_PageCount = i_PageCount.ToString();

        string strRecordTemp = string.Empty;
        strRecordTemp = Convert.ToString(i_CurrentPage * 4);
        string strSql = string.Empty;

        if (s_CurrentPage == "0")
        {
            strSql = "select top 4 *  from Users order by Id DESC";
        }
        else
        {
            strSql = "select top 4 * from Users  where Id not in (select top " + strRecordTemp + " Id from Users order by ID DESC) order by Id DESC";
        }
        SqlDataReader  Rdlist = SqlHelper.ExecuteReader(strConn, strSql, null);
        DataTable Dt = new DataTable();
        DataRow dr;
        //F_Code,F_Name,F_Sex,F_Title,F_Email,F_feeling,F_facepic,F_From,F_Tel,F_Mobile,F_Replay,F_bHaveReplay,F_AddTime,F_ip,F_Book,F_show

        Dt.Columns.Add("Id", typeof(int));//0
        Dt.Columns.Add("YongHu", typeof(string));//1
        Dt.Columns.Add("Passwod", typeof(string));//2
        Dt.Columns.Add("PasswordTips", typeof(string));//3
        Dt.Columns.Add("PasswordAnswer", typeof(string));//4
        Dt.Columns.Add("Type", typeof(int));//5
        Dt.Columns.Add("RegistDateTime", typeof(string));//6

        while (Rdlist.Read())
        {
            dr = Dt.NewRow();
            dr[0] =Convert.ToInt16(Rdlist[0]);
            dr[1] = Rdlist[1].ToString();
            dr[2]=  Rdlist[2].ToString();
            dr[3] = Rdlist[3].ToString();
            dr[4] = Rdlist[4].ToString();
            dr[5] =Convert.ToInt16(Rdlist[5]);
            dr[6] = Rdlist[6].ToString();
            Dt.Rows.Add(dr);
        }
        Rdlist.Close();

        this.Repeater1.DataSource = new DataView(Dt);
        this.Repeater1.DataBind();
    }
      protected override void Render(HtmlTextWriter writer)
      {

          if (i_RecordCount > 0)
          {
              StringBuilder sp = new StringBuilder();
              sp.AppendLine("<div style=\"width:100%;font-size:12px;\">");
              sp.Append("    共&nbsp;");
              sp.Append(s_RecordCount);
              sp.Append("&nbsp;条记录");
              sp.Append("    &nbsp;");
              if (i_PageCount > 1)
              {
                  if (i_CurrentPage == 0)
                  {
                      sp.AppendLine("<a  href=\"javascript:Paging(" + Convert.ToString(i_CurrentPage + 1) + ")\" style=\"text-decoration:none;height:17px;\">下一页</a>");
                      sp.AppendLine("&nbsp;");
                      sp.AppendLine("<a  href=\"javascript:Paging(" + Convert.ToString(i_PageCount - 1) + ")\" style=\"text-decoration:none;height:17px;\">末页</a>");
                      sp.AppendLine("&nbsp;&nbsp;");
                  }
                  else
                  {
                      if (Convert.ToInt32(i_CurrentPage + 1) == i_PageCount)
                      {
                          sp.AppendLine("<a  href=\"javascript:Paging(0)\" style=\"text-decoration:none;height:17px;\">首页</a>");
                          sp.AppendLine("&nbsp;");
                          sp.AppendLine("<a  href=\"javascript:Paging(" + Convert.ToString(i_CurrentPage - 1) + ")\" style=\"text-decoration:none;height:17px;\">上一页</a>");
                          sp.AppendLine("&nbsp;");
                      }
                      else
                      {
                          sp.AppendLine("<a  href=\"javascript:Paging(0)\" style=\"text-decoration:none;height:17px;\">首页</a>");
                          sp.AppendLine("&nbsp;");
                          sp.AppendLine("<a  href=\"javascript:Paging(" + Convert.ToString(i_CurrentPage - 1) + ")\" style=\"text-decoration:none;height:17px;\">上一页</a>");
                          sp.AppendLine("&nbsp;");
                          sp.AppendLine("<a  href=\"javascript:Paging(" + Convert.ToString(i_CurrentPage + 1) + ")\" style=\"text-decoration:none;height:17px;\">下一页</a>");
                          sp.AppendLine("&nbsp;");
                          sp.AppendLine("<a  href=\"javascript:Paging(" + Convert.ToString(i_PageCount - 1) + ")\" style=\"text-decoration:none;height:17px;\">末页</a>");
                          sp.AppendLine("&nbsp;&nbsp;");
                      }
                  }
              }
              sp.AppendLine("<span >共" + s_PageCount + "页,当前第" + Convert.ToString(i_CurrentPage + 1) + "页</span>");
              sp.AppendLine("</div>");


              writer.Write(sp.ToString());

          }



          this.Repeater1.RenderControl(writer);

      }
      protected void LinkButton1_Click(object sender, EventArgs e)
      {
          try
          {
              LinkButton lb = (LinkButton)sender;
              int id = 0;
              int.TryParse(, out id);
              int i = Users.Delete(id);
              if (i > 0)
              {
                  UserMatter.Add(id, (int)UserMatter.MatterType.ShanChu, "删除用户" + Users.GetField(id, "YongHu"));
                  //UserMatter.Add(id, (int)UserMatter.MatterType.ShanChu, "删除用户详细信息" + Users.GetField(id, "YongHu")); //尚未实现删除用户的同时也删除用户详细信息
                  MBox.RefUrl(2);
              }
              else
              {
                  Response.Redirect("Error.aspx");
              }
          }
          catch
          {
              Response.Redirect("Error.aspx");
          }
      }
    }
}




希望高手帮忙解决下
搜索更多相关主题的帖子: ajax 排版 
2010-04-27 14:38
misswang
Rank: 8Rank: 8
来 自:湖北荆州
等 级:贵宾
威 望:15
帖 子:265
专家分:720
注 册:2010-3-11
收藏
得分:0 
你的数据要是用数据绑定控件的话,样式就好看多了

misswp2010@
wangping103@
2010-04-27 19:04
等待冰柠檬
Rank: 2
来 自:浙江温州
等 级:论坛游民
帖 子:208
专家分:70
注 册:2008-6-25
收藏
得分:0 
我不是用Repeater绑定的么?怎么还会这样?
2010-04-27 19:12
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
觉得应该是你的样式不同造成的吧,我看你的html代码里每个单元格的样式好想都不一样

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2010-04-28 17:08
等待冰柠檬
Rank: 2
来 自:浙江温州
等 级:论坛游民
帖 子:208
专家分:70
注 册:2008-6-25
收藏
得分:0 
但是列里面都都没对齐啊!
2010-04-28 23:41
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
怀疑是你的数据有问题,可能存在空格,你没发现“修改”那列很齐吗?就那列不用显示数据

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2010-04-29 10:45
等待冰柠檬
Rank: 2
来 自:浙江温州
等 级:论坛游民
帖 子:208
专家分:70
注 册:2008-6-25
收藏
得分:0 
可是把数据的空格过滤掉还是一样的。。。。。
程序代码:
 <tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22" >
    <td class="style1"><a href="DetailsManager.aspx?userid=<%#DataCommon.Users.GetUserid(Eval("YongHu").ToString())%>"><%#Eval("YongHu").ToString().Trim()%></a></td>
    <td class="style1"><%#Eval("Passwod").ToString().Trim()%></td>
    <td class="style3"><%#DataCommon.Users.Gettype(int.Parse(Eval("Type").ToString())).Trim()%></td>
    <td class="style1"><%#Eval("RegistDateTime").ToString().Trim()%></td> 
    <td class="style4">
    <a href="UserManager.aspx?id=<%#Eval("Id")%>">修改</a>
    <asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="return confirm('您确定删除吗')" CommandArgument='<%#Eval("Id")%>' OnClick="LinkButton1_Click">删除</asp:LinkButton>
    </td>
    </tr>

 
2010-04-29 13:20
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
不一样,英文空格和中文的空格不一样,并且日文的空格和中文的也不一样,说白了就是各种语言的空格之间都是不一样的
Trim()只能过滤英文的空格

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2010-04-29 17:44
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
你应该看看数据库里是不是有空格,数据库里的空格是很讨厌的,最好是去掉。
还有你也可以试试在trim的基础上replace掉中文空格,看看效果如何

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2010-04-29 17:51
等待冰柠檬
Rank: 2
来 自:浙江温州
等 级:论坛游民
帖 子:208
专家分:70
注 册:2008-6-25
收藏
得分:0 
还是一样的......
2010-05-02 17:39
快速回复:js ajax分页的排版问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039667 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved