【发布时间】:2010-12-16 17:33:43
【问题描述】:
我想根据 EventStartDate 启用或禁用“ParticipateBtn”。我收到此错误:对象引用未设置为对象的实例。
开始日期 :
<asp:Button runat="server"
ID="ParticipateBtn"
CommandName="Participate"
CommandArgument='<%# Eval("Event_Id") + "|" + Eval("Event_Name") + "|" + Eval("Volume") + "|" + Eval("Tournament_Id") %>'
Text="Participate" />
</ItemTemplate>
<FooterTemplate></FooterTemplate>
<SeparatorTemplate>
<hr style="color:Silver; height:1px;" />
</SeparatorTemplate>
</asp:Repeater>
背后的代码...
//Code behind
protected string CheckEnability(DateTime eventstartdate)
{
if (eventstartdate.Date < DateTime.Now.Date)
{
Button btn = (Button)Repeater1.FindControl("ParticipateBtn");
btn.Enabled = false;
}
return eventstartdate.ToString("yyyy-MM-dd");
}
【问题讨论】:
标签: c# asp.net controls repeater