Recently, I was working on a project when I came into a problem that I hadn’t dealt with before. You see I was working with a rather large table (200+ fields) and a corresponding archive table for it. The goal was to be able to populate a form with fields from either of the object types as essentially they were the same record type.
With the implementation of MVC there is a lot more room for unhanded global exceptions because in MVC you are encouraged to write more in line code to accompany the back end code. So what happens when an exception is thrown within the front end code? Well you’ll have an exception that will bubble up to the global application class which if you don’t handle it there it will continue to bubble and be displayed to the user as specified in the web configuration file. This doesn’t do you much good, sure the user will know that there is an error, and you can squelch the amount of information that is displayed to your ordinary users, but if working through trouble shooting the issue this basic information does you no good.
There are a number of different reasons that you would want to get your database results in a random order. I’ve had a number of different reasons to do this so far throughout my career, the first of which was in a simple T-SQL statement that we were pulling up a list of items that we wanted in a random order. Turns out that with T-SQL there is a really simple way to get your results in a random order. All you have to do is add the following to the end of your SQL statement.
Recently we had a client ask us to add a label in front of the paging control on an ASP.NET gridview numeric paging control so that users would know what the numbers meant. This seemed like a reasonable request as we were dealing with users who may not be the most tech savvy, plus it didn’t seem like there would be much work that would need to be put in to accomplish this goal. To understand the solution you need to understand the steps at which it took to get there.
The first thing I tried was modifying the PagerTemplate, but little did I know that in ASP.NET when you modify this template on a GridView you overwrite the entire paging control. This obviously wasn’t what I wanted, I just needed to add a little text in front of all the page numbers, I didn’t want to rewrite it entirely.