Refactor Code

  • Gravatar
    Repetitive UI Code

    by azamsharp on 5/20/2008 7:58:57 AM
  • Not sure what is the best practice on this but I see that a lot of times I write repetitive UI code. I am mainly talking about GridView in-place editing code where you need to attach the Row_Updating, Row_Editing events. ASP.NET Dynamic Website fixes this issue to some extent. But what are some other fixes to this problem.
  • Updating_Row
    {
    // same code is repeated for each domain object
    }

    Editing_Row
    {
    // same code is repeated for each domain object
    }
  • Refactor it!
  • Gravatar
    The easiest method I found was to just create a UI that inherits the GridView. Inside that, override the Row_Updating and Row_Editing event methods. This will only work if you use the same code over again. Your other solution would be to create static methods and delegates that can be added to the Row_Updating and Row_Editing events so that they will be called when the event is thrown. This would mean only 2 lines of code for each gridView versus the separate function pair for each gridview.
    by dudeserius on 7/29/2008 1:03:04 PM
Please log in to refactor the code! Login