Geeks With Blogs
Will Smith The Blog in Black March 2008 Entries
MVC and ASP.Net Server Controls
In a recent post, I mentioned that I was working on a customized grid view. Last week I completed the "binding to user settings" behavior. Then I took a look at the source and was stunned. I had almost 700 lines of code (and comments) and it wasn't well organized. So, I set out to start adding regions to the code to separate different behavior. The last sentence should have raised some flags. Regions to separate behavior? What happened to the cohesion of my grid view? I seem to have lost sight of ......

Posted On Monday, March 24, 2008 10:06 AM

Red, Green, Refactor
There are some key practices that all Agile developers should be familiar with. In fact, "familiar" probably isn't strong enough. One of these practices is test-driven development (TDD). As one of the most important activities it ironically requires a lot of discipline. What does Red-Green-Refactor mean? Here is a brief description. There are plenty of places to learn about TDD and Refactoring in more depth. Red: write a test (it fails of course) Green: write the least amount of code (the simplest ......

Posted On Tuesday, March 18, 2008 11:59 AM

More Fun With Extension Methods
C# 3.0 has certainly introduced some really cool features. I have used the Automatic Properties extensively as well as object and collection initializers. These are real time savers. However, the most exciting feature (IMHO) are Extension Methods. My last post shows one example of how powerful extension methods can be. Here is another example (inspired by Scott Gu). 1: public static class Extensions 2: { 3: /// 4: /// Do not use this extension for large sets because it iterates through 5: /// the ......

Posted On Thursday, March 13, 2008 11:26 AM

ViewState Extension Method
How many times have you written something like this? 1: public string MyStringProperty 2: { 3: get 4: { 5: object s = ViewState["MyStringProperty"]; 6: if( s == null ) 7: { 8: s = "MyDefaultValue"; 9: } 10: return (String)s; 11: } 12: set { ViewState["MyStringProperty"] = value; } 13: } 14: 15: public bool MyBooleanProperty 16: { 17: get 18: { 19: object b = ViewState["MyBooleanPropert... 20: if( b == null ) 21: { 22: b = true; 23: } 24: return (bool)b; 25: } 26: set { ViewState["MyBooleanProperty"] ......

Posted On Monday, March 10, 2008 1:44 PM

My first AJAX (sorta)
So, I decided to put my custom GridView in a AJAX UpdatePanel. This was my first serious exposure to AJAX (asp.net). I discovered that I was having major problems. I kept getting an "unspecified error". Because it occurred whenever I clicked on a row, I assumed it had to do with the JavaScript I wrote for the GridView. I did tons of web searching about how to properly use script in a controlled wrapped in an update panel. I tried a few things, including embedding the script and registering the script ......

Posted On Sunday, March 9, 2008 10:13 PM

Custom GridView
A few nights ago I decided to work on a custom GridView. My goal (derived from a customer request) was to build some additional behavior into the GridView without having to write a whole bunch of client-side or code-behind code. These are the things that I am focusing on: Select a row when the user clicks on it (no CheckBox) Allow the user to select multiple rows (using Shift and Ctrl keys) Bind display settings to site preferences Column header text Bind display settings to user preferences Columns ......

Posted On Friday, March 7, 2008 1:28 PM

Oracle Merge To Self
I encountered a problem with Oracle's MERGE DML yesterday. What I was trying to do is use the "Upsert" feature of the merge, except with no distinct source. All of the searching I did for the MERGE showed examples of how to merge data from a source into a target. In my case, I thought the source and the target were the same. This is what I initially tried. It didn't work. It turns out that if the source (s) returns an empty set, then the merge is effectively a no-op 1: merge into MY_TARGET t 2: using ......

Posted On Wednesday, March 5, 2008 12:53 AM

Generic Conversion for DBNull and Nullable types
It seems that I have encountered a scenario where many aspects of C# 2.0+ come into play. I needed to handle conversion from an IDataReader.GetValue() result to a generic type, including Nullable<>. It took me a while to figure it out and with a little help from this snippet, I was quite please with the result. So, I decided to share. 1: private static T NullValue<T>( object testValue, T nullValue ) 2: { 3: T returnValue; 4: if( testValue is DBNull ) 5: { 6: returnValue = nullValue; 7: ......

Posted On Tuesday, March 4, 2008 11:26 PM

TeamCity... mmm Good.
I recently switched over to TeamCity from CC.Net. Normally, like most people, I hate change. But, while it took me a while to figure out the new way of configuring a build, it was certainly worth it. Some of the benefits: Being able to copy a configuration to easily start configuration of another. Nifty "pause" feature. Taking responsibility for broken builds Easily viewing build logs in the web interface Client tools (tray, ide integration) I am sure there are others. The list above are benefits ......

Posted On Tuesday, March 4, 2008 6:25 PM

SVN Hiccup
I introduced my boss to Subversion recently, and of course he almost immediately had a problem. It turns out that as soon as he added his computer to a different domain Tortoise wasn't working on his existing projects. My guess is that it had to do with the Computer Name change. The symptoms he saw as that Tortoise was not recognizing that he made changes. In fact, neither the Update nor the Commit menu options were showing up. Tortoise was clearly confused. We tried a number of things including ......

Posted On Monday, March 3, 2008 3:07 PM

DataSourceControl - WOW!
So, I learned something new yesterday. I haven't spent a lot of time in ASPX over the last couple of years, and when I did I didn't really pay attention to what is new. Well, I learned about the nifty DataSourceControl classes. In my case, I decided to use the LinqDataSource control. And I put it to use on a nested GridView with Paging I struggled for more hours than I care to admit to accomplish what I wanted. In the end, I was pleased at just how little code was required. Check out my full article ......

Posted On Saturday, March 1, 2008 9:38 PM

Copyright © Will Smith | Powered by: GeeksWithBlogs.net | Join free