我有一个如下的GridView: asp:GridView ID="Results" runat="server" OnRowDataBound="Results_RowDataBound" EmptyDataTemplateNo results found/EmptyDataTemplate/asp:GridViewProtected Sub Results_RowDataBound(ByVal sender As Object, ByVal
<asp:GridView ID="Results" runat="server" OnRowDataBound="Results_RowDataBound"> <EmptyDataTemplate>No results found</EmptyDataTemplate> </asp:GridView> Protected Sub Results_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) 'do a bunch of work here End Sub
根据用户输入,有时我想要触发OnRowDataBound事件,有时我不想.
有没有办法以编程方式打开或关闭事件?
以下是编程为 add and remove events in VB.NET的示例代码:If CheckBox1.Checked Then AddHandler Results.RowDataBound, AddressOf Results_RowDataBound Else RemoveHandler Results.RowDataBound, AddressOf Results_RowDataBound End If