编译器错误信息: CS1519: 类、结构或接口成员声明中的标记“=”无效源错误:行 60: */
行 61: /*p.Pindex=pagei.ToString();*/
行 62: p.Pindex=1;  错误行
行 63: p.Pcount=pds.PageCount;
行 64: </script>
行62是错误行我的代码<script language="c#" runat="server">
 void page_load(){
  string strconn="server=A2\\www;uid=sa;pwd=xinhailong;database=student";
string strsql="select name,age,id from student";
SqlConnection objconn=new SqlConnection(strconn);
objconn.Open();
SqlDataAdapter objdap=new SqlDataAdapter(strsql,objconn);
DataTable dtab=new DataTable();
objdap.Fill(dtab);
System.Web.UI.WebControls.PagedDataSource pds=new System.Web.UI.WebControls.PagedDataSource();
pds.DataSource=dtab.DefaultView;
pds.AllowPaging=true;
pds.PageSize=2;
pds.CurrentPageIndex=1;//第一页的索引值是0
show.DataSource=pds;
show.DataBind();
 }
 public class Pages:System.Web.UI.Page
 {
  private int pindex;
private int pcount;
public int Pindex{
set {
pindex=value;
}
}
public int Pcount{
set {
pcount=value;
}
}
public string strlink(){
int i;
string slink=null;
for (i=1;i<=pcount;i++){
if (i!=pindex){
slink=slink+"<a href=?page="+i.ToString()+">第"+i.ToString()+"页</a>&nbsp;";
}
else{
slink=slink+"第"+i.ToString()+"页&nbsp;";
}
}
return slink;
}
 }
 Pages p=new Pages();
/* string pagei=Request.QueryString["page"];
 if (pagei==null){
  pagei="1";
}
*/
/*p.Pindex=pagei.ToString();*/
p.Pindex=1;
p.Pcount=pds.PageCount;
</script>
</head>
<body>
<asp:Repeater ID="show" runat="server">
<itemtemplate>
<%#DataBinder.Eval(Container.DataItem,"name")%>
</itemtemplate>
<headertemplate>
repeater控件分页演示
</headertemplate>
<footertemplate>
<%#p.strlink()%>
</footertemplate>
</asp:Repeater>
 

解决方案 »

  1.   

    狂晕,自定义类为什么要派生自System.Web.UI.Page?
    你这个类看上去不是一个页面啊
      

  2.   

    先把:System.Web.UI.Page去掉再说
    每当看见这样的问题我就肚子痛~
      

  3.   

    Pages p=new Pages();
    /* string pagei=Request.QueryString["page"];
     if (pagei==null){
      pagei="1";
    }
    */
    /*p.Pindex=pagei.ToString();*/
    p.Pindex=1;
    p.Pcount=pds.PageCount;上面这几行代码没有在一个类里面,是孤立的,.Net好像不允许这样。
    所有的变量、方法必须在一个类里面
      

  4.   

    我把System.Web.UI.Page去了也不行呀.
    还是提示相同的错误.
      

  5.   

    zhjg136(天星) ( )说的有道理
      

  6.   

    /*
    我把System.Web.UI.Page去了也不行呀.
    还是提示相同的错误
    */
    我指出的是你更严重的问题
    而不是仅仅解决这一个错误
      

  7.   

    我是想写在.cs里.但是我不会在页面里引用.cs代码呀.我是新手.
    维也纳说说呀.你的msn号是多少.想麻烦你.呵呵