我想启用或禁用'ParticipateBtn',具体取决于EventStartDate.我收到此错误:对象引用未设置为对象的实例.
开始日期:<%#CheckEnability((DateTime)Eval("Event_Start_Date"))%>
<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>
Run Code Online (Sandbox Code Playgroud)
背后的代码......
//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");
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用C#进行屏幕刮擦.它可以工作几次,之后我收到会话过期错误.任何帮助将不胜感激.