asp.net 找不到控件。
前台代码:<tablewidth="500"border="0"cellpadding="0"cellspacing="1"bgcolor="#CCCCCC"class=...
前台代码:
<table width="500" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC" class="list">
<asp:Repeater ID="rptGoodsType" runat="server" onitemcommand="rptGoodsType_ItemCommand">
<HeaderTemplate>
<tr>
<th height="40">商品类别名称</th>
<th>操作</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("goodsTypeName") %></td>
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="更新" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="取消" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
<asp:HyperLink ID="prevPage" runat="server">上一页</asp:HyperLink>
<asp:HyperLink ID="nextPage" runat="server">下一页</asp:HyperLink>
<asp:Label ID="lblCurrentPage" runat="server"></asp:Label>
</td>
</tr>
</FooterTemplate>
</asp:Repeater>
</table>
后台代码:
protected void Page_Load(object sender, EventArgs e)
{
DataAccess myData = new DataAccess();
DataSet ds = myData.GetAllGoodsType();//自己定义的,值已经获取到了
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 5;
int CurPage;
//当前页面从Page查询参数获取
if (Request.QueryString["Page"] != null)
CurPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage=1;
objPds.CurrentPageIndex = CurPage-1;
lblCurrentPage.Text = "Page: " + CurPage.ToString();
if (!objPds.IsFirstPage)
{
prevPage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
}
if (!objPds.IsLastPage)
{
nextPage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
}
//把PagedDataSource 对象赋给Repeater控件
rptGoodsType.DataSource=objPds;
rptGoodsType.DataBind();
}
protected void rptGoodsType_ItemCommand(object source, RepeaterCommandEventArgs e)
{
}
救救我吧:
编译器错误消息: CS0103: 当前上下文中不存在名称“lblCurrentPage”
编译器错误消息: CS0103: 当前上下文中不存在名称“prevPage”
编译器错误消息: CS0103: 当前上下文中不存在名称“nextPage”
把这三项注释了就好使,或者把这3个控件不放在 FooterTemplate里就好使,为什么FooterTemplate里的控件获取不到?
我确实是粘贴过来的代码。 怎么切换都不好使。 展开
<table width="500" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC" class="list">
<asp:Repeater ID="rptGoodsType" runat="server" onitemcommand="rptGoodsType_ItemCommand">
<HeaderTemplate>
<tr>
<th height="40">商品类别名称</th>
<th>操作</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("goodsTypeName") %></td>
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="更新" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="取消" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
<asp:HyperLink ID="prevPage" runat="server">上一页</asp:HyperLink>
<asp:HyperLink ID="nextPage" runat="server">下一页</asp:HyperLink>
<asp:Label ID="lblCurrentPage" runat="server"></asp:Label>
</td>
</tr>
</FooterTemplate>
</asp:Repeater>
</table>
后台代码:
protected void Page_Load(object sender, EventArgs e)
{
DataAccess myData = new DataAccess();
DataSet ds = myData.GetAllGoodsType();//自己定义的,值已经获取到了
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 5;
int CurPage;
//当前页面从Page查询参数获取
if (Request.QueryString["Page"] != null)
CurPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage=1;
objPds.CurrentPageIndex = CurPage-1;
lblCurrentPage.Text = "Page: " + CurPage.ToString();
if (!objPds.IsFirstPage)
{
prevPage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
}
if (!objPds.IsLastPage)
{
nextPage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
}
//把PagedDataSource 对象赋给Repeater控件
rptGoodsType.DataSource=objPds;
rptGoodsType.DataBind();
}
protected void rptGoodsType_ItemCommand(object source, RepeaterCommandEventArgs e)
{
}
救救我吧:
编译器错误消息: CS0103: 当前上下文中不存在名称“lblCurrentPage”
编译器错误消息: CS0103: 当前上下文中不存在名称“prevPage”
编译器错误消息: CS0103: 当前上下文中不存在名称“nextPage”
把这三项注释了就好使,或者把这3个控件不放在 FooterTemplate里就好使,为什么FooterTemplate里的控件获取不到?
我确实是粘贴过来的代码。 怎么切换都不好使。 展开
12个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询