Development – Leet 4 Life

Software Development Code Samples and More

Skip to: Content | Sidebar | Footer

Tag: C#.NET

Modifying the ASP.NET GridView Paging Control

29 March, 2012 | ASP.NET, C#. NET | By: Michael Merrell

The paging control that is built into the ASP.NET grid view is very handy indeed, however the template controls for the grid view leave some to be desired. If you need to add something or get more control over how the paging control is displayed it can cause a great deal of head ache trying to figure out the best way to do so. In my case I needed to add a simple text value before the paging numbers to show that they were page indicators. Below you will find the code I used to add a ‘Page’ label to [Read More…]

Converting a Value Back to an Enumeration

23 March, 2012 | C#. NET | By: Michael Merrell

Stored enumeration values need a way to be converted back to to their enumeration type.  In a previous post I go into detail on how to get the values on an enumeration and return them in a usable data format.  This is great if we want to store the value in the database, but when you pull the value back out you need to have a way to convert it back into something usable.   There are two methods defined below, both take in a Type parameter and then a value parameter.  The first method below also takes in a default value in [Read More…]

Using an Enumeration as a Data Source

12 March, 2012 | C#. NET | By: Michael Merrell

Enumerations have many uses but one use that doesn’t get much attention is using an enumeration as a data source.   I have written two methods that will take in an enumeration (Either Type name as string or the actual Type) and then return a dictionary of all the name/value pairs.  All enumerations have a numerical value, whether the actual values are defined specifically or automatically populated is up to the developer.  A long is used here as all values that can be defined for an enumeration will convert to a long value.  However, you can also assign an integer or byte value [Read More…]

Creating an Expandable Custom Collection in C# .NET

26 February, 2012 | C#. NET | By: Michael Merrell

There comes a time where you occasionally will need to extend the functionality of an existing object or type. Say for instance you want to add the ability for a List object to return a concatenated string of it’s contained values. Or you want to have the ToString method return an XML String representation of your current collection. To do this in more you you simply need to create a new class that inherits from IList and then you have the flexibility to do whatever you want to do including the ability to have logic around preventing the removal of [Read More…]

Looping Through Multiple/Nested Repeaters

15 February, 2012 | ASP.NET, C#. NET | By: Michael Merrell

Have you ever needed to loop through multiple repeater objects to find a set of controls within or loop through a repeater nested within another repeater? It’s gotten to a point now where there have been multiple instances of each scenario now that I have had to use either a repeater nested within a repeater or two nearly-identical repeaters that I had needed to loop through both in order to find specific identical controls within each one. Below you will find my code example on how to loop through multiple repeaters as well as how to loop through a repeater [Read More…]