编译器错误信息: 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> ";
}
else{
slink=slink+"第"+i.ToString()+"页 ";
}
}
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>
行 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> ";
}
else{
slink=slink+"第"+i.ToString()+"页 ";
}
}
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>
解决方案 »
- asp.net 文章浏览次数??
- 怎样查看支付宝登录页面的详单信息
- 一个SQL问题 help me
- 有谁知道这个网页的分页规则是什么吗?怎样直接在地址栏输入第二页的网址?
- 下拉框连动问题。??
- 请大家帮忙看看下面这几句代码哪里错了
- Textbox 文本内容获取问题
- Programming Microsoft Asp Net 2.0 Core Reference关于ADO.net那部分,怎么写得乱七八糟的?
- 疑惑,讨论WebService + XML实现无刷新的问题,在线等!(附代码)
- 请教如何在datagrid中不出现标题行
- 发布一个能改变样式的上传控件!
- 数据库中提取的数据在网页中以表格的形式显示,结果查找当前页出错。
你这个类看上去不是一个页面啊
每当看见这样的问题我就肚子痛~
/* string pagei=Request.QueryString["page"];
if (pagei==null){
pagei="1";
}
*/
/*p.Pindex=pagei.ToString();*/
p.Pindex=1;
p.Pcount=pds.PageCount;上面这几行代码没有在一个类里面,是孤立的,.Net好像不允许这样。
所有的变量、方法必须在一个类里面
还是提示相同的错误.
我把System.Web.UI.Page去了也不行呀.
还是提示相同的错误
*/
我指出的是你更严重的问题
而不是仅仅解决这一个错误
维也纳说说呀.你的msn号是多少.想麻烦你.呵呵