我用DataList控件显示新闻列表,在显示的时候我想在后直接求取系的时间(5/15),
我直接在链接列表的后面定义了一个label控件,然在在后台求取系的时间
前台代码:
<asp:DataList ID="dlSZ" runat="server">
<ItemTemplate>
<table class="txt" >
<tr><td style="width:1px;"></td> <td style="width:300px">
· <asp:LinkButton ID="LinkButton1" ForeColor="#660033" runat="server" CommandName="select" ><%# DataBinder.Eval(Container.DataItem,"title") %> </asp:LinkButton>
</td>
<td style="width:10px" > <asp:Label ID="Label1" runat="server" Text="Label1"></asp:Label> </td> </tr>
</table>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<AlternatingItemStyle Font-Bold="False" />
</asp:DataList>
后台代码:
public partial class _Default : System.Web.UI.Page
{
BaseClass bc = new BaseClass();
protected void Page_Load(object sender, EventArgs e)
{
dlSZ.DataSource = bc.GetDataSet("SELECT TOP 10 * FROM xinwen WHERE (Type = '国内新闻')", "xinwen");
dlSZ.DataKeyField = "id";
dlSZ.DataBind();
DataList1.DataSource = bc.GetDataSet("SELECT TOP 5 * FROM tbtu order by addDate desc", "tbtu");
DataList1.DataKeyField = "id";
DataList1.DataBind();
Label1.Text = System.DateTime.Now.ToString(MM / dd);
}
错误提示:
当前上下文中不存在名称“Label1”