Convert C# (with typed events) to VB.NET
- by Steven
I have an ASPX page (with VB Codebehind). I would like to extend the GridView class to show the header / footer when no rows are returned.
I found a C# example online (link) (source). However, I cannot convert it to VB because it uses typed events (which are not legal in VB).
I have tried several free C# to VB.NET converters online, but none have worked.
Please convert the example to VB.NET or provide an alternate method of extending the GridView class.
Notes / Difficulties:
If you get an error with DataView objects, specify the type as System.Data.DataView and the type comparison could be the following: If data.[GetType]() Is GetType(System.Data.DataView) Then
Since the event MustAddARow cannot have a type in VB (and RaiseEvent event doesn't have a return value), how can I compare it to Nothing in the function OnMustAddARow()?
EDIT:
The following is a sample with (hopefully) relevant code to help answer the question.
namespace AlwaysShowHeaderFooter {
public delegate IEnumerable MustAddARowHandler(IEnumerable data);
public class GridViewAlwaysShow : GridView {
//////////////////////////////////////
// Various member functions omitted //
//////////////////////////////////////
protected IEnumerable OnMustAddARow(IEnumerable data) {
if (MustAddARow == null) {
throw new NullReferenceException("The datasource has no rows. You must handle the \"MustAddARow\" Event.");
}
return MustAddARow(data);
}
public event MustAddARowHandler MustAddARow;
}
}