ASP.NET MVC - Code Usability Improvement (available now in v2011.1)

ASP.NET Team Blog
15 April 2011

Available now in the DXperience v2011.1 release, we've introduced a useful improvement for working with the DevExpress ASP.NET MVC Extensions that will help improve code usability.

Add Method For Collections

We're adding a useful new overload for our collections' Add methods. So the fluent HTML code in our MVC Extensions that looked like this:

var column = settings.Columns.Add("Total");
column.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
column.PropertiesEdit.DisplayFormatString = "c";

Will now look like this with v2011 volume 1 release:

settings.Columns.Add(column => { 
    column.FieldName = "Total";
    column.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
    column.PropertiesEdit.DisplayFormatString = "c";
})

Benefits

The benefit for you with the new Add method is that it avoids the var structure and makes your code more readable!

Thanks to a DevExpress customer who asked me during a recent webinar about using more lambda expressions in our MVC extensions.

What do you think of this code improvement? Drop me a line below, thanks!

Build Your Best - Without Limits or Compromise

Try the DevExpress ASP.NET MVC Extensions online now: http://mvc.devexpress.com

Read the latest news about DevExpress ASP.NET MVC Extensions

Download a free and fully-functional version of DXperience now: http://www.devexpress.com/Downloads/NET/

Follow MehulHarry on Twitter

2 comment(s)
Graeme Ross
Graeme Ross

Great improvement, any chance this will be included for settings/properties.

settings.SettingsPager(sp => {

    sp.AllButton.Visible = true;

    sp.AlwaysShowPager = true;

    sp.Position = PagerPosition.TopAndBottom;

});

15 April, 2011
Mehul Harry (DevExpress)
Mehul Harry (DevExpress)

Graeme,

Thanks! And it's possible so we'll consider it for a future release.

18 April, 2011

Please login or register to post comments.