Convert C# (with typed events) to VB.NET

Posted by Steven on Stack Overflow See other posts from Stack Overflow or by Steven
Published on 2010-04-22T20:06:36Z Indexed on 2010/04/22 21:33 UTC
Read the original article Hit count: 195

Filed under:
|
|

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:

  1. 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

  2. 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;

    }

}

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about c#