<form id="form1" runat="server">
<asp:DataList ID="DataList1" runat="server" ShowFooter="true" ShowHeader="true"><ItemTemplate>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TR>
<TD height=25 style="width: 295px" align=left>标题:<%# DataBinder.Eval(Container.DataItem,"title")%> </TD>
<TD height=25>留言者:<%# DataBinder.Eval(Container.DataItem,"writer")%></TD>
</TR>
<TR>
<TD colspan="2" style="padding-left:30px;height: 8px;" align=left><%# DataBinder.Eval(Container.DataItem,"content")%></TD>
</TR>
<TR>
<TD height=15 style="width: 295px"> </TD>
<TD width="35%">发布日期:<%# DataBinder.Eval(Container.DataItem,"times")%></TD>
</TR>
<TR>
<TD height=5 colspan="2"></TD>
</TR>
</TABLE>
</ItemTemplate> <FooterTemplate>
<table cellSpacing=0 cellPadding=0 width="100%" border=0>
<TR>
<td>
第<asp:Label ID="count" runat="server"></asp:Label>页
<asp:LinkButton ID="first" runat="server" OnClick="first_Click">首页</asp:LinkButton>
<asp:LinkButton ID="pre" runat="server">上一页</asp:LinkButton>
<asp:LinkButton ID="next" runat="server">下一页</asp:LinkButton>
<asp:LinkButton ID="last" runat="server">尾页</asp:LinkButton>
</td>
</TR>
</TABLE>
</FooterTemplate>
</asp:DataList>
</form>上面代码是页面的,我在该页面的cs窗体代码不能找到Label的对象,label1.text没有,还有first,pre等都没,怎么回事?
<asp:DataList ID="DataList1" runat="server" ShowFooter="true" ShowHeader="true"><ItemTemplate>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TR>
<TD height=25 style="width: 295px" align=left>标题:<%# DataBinder.Eval(Container.DataItem,"title")%> </TD>
<TD height=25>留言者:<%# DataBinder.Eval(Container.DataItem,"writer")%></TD>
</TR>
<TR>
<TD colspan="2" style="padding-left:30px;height: 8px;" align=left><%# DataBinder.Eval(Container.DataItem,"content")%></TD>
</TR>
<TR>
<TD height=15 style="width: 295px"> </TD>
<TD width="35%">发布日期:<%# DataBinder.Eval(Container.DataItem,"times")%></TD>
</TR>
<TR>
<TD height=5 colspan="2"></TD>
</TR>
</TABLE>
</ItemTemplate> <FooterTemplate>
<table cellSpacing=0 cellPadding=0 width="100%" border=0>
<TR>
<td>
第<asp:Label ID="count" runat="server"></asp:Label>页
<asp:LinkButton ID="first" runat="server" OnClick="first_Click">首页</asp:LinkButton>
<asp:LinkButton ID="pre" runat="server">上一页</asp:LinkButton>
<asp:LinkButton ID="next" runat="server">下一页</asp:LinkButton>
<asp:LinkButton ID="last" runat="server">尾页</asp:LinkButton>
</td>
</TR>
</TABLE>
</FooterTemplate>
</asp:DataList>
</form>上面代码是页面的,我在该页面的cs窗体代码不能找到Label的对象,label1.text没有,还有first,pre等都没,怎么回事?
最后是把,这些分页的Button放到datalist的外面了。不放里面,直接操作
{
if (e.Item.ItemType == ListItemType.Footer)
{
if (e.Item.FindControl("Label2") != null)
{
((Label)e.Item.FindControl("Label2")).Text = string.Format("总录总数:{0}", GetData().Count);
}
}
}