ASP.NET 3.5 brought us some really cool controls like the ListView control and the DataPager control. My biggest gripe though is that the DataPager doesn't use a block level element to encapsulate it. It uses a <span> element instead. So is using the DataPager a forgone loss? No way! All we have to do is play the inheritance game and we can override that goofy choice of a <span>.
Fire up a new Class Library project and create a new class. Make sure to add references to the following namespaces:
Since we don't want to have to reinvent all the things that a DataPager does, we can just inherit all its attributes and behaviors. Now, all we have to do is add the following method:
That's it! Now save the class and create a new web application. Add a reference to the newly created class library, create a new page, and add the following directive to the top:
<%@ Register Namespace="WhatEverTheNamespaceIs" Assembly="WhatEverTheAssemblyNameIs" TagPrefix="Prefix" %>
Now, you should be able to add