Thoughts from Dan Miser RSS 2.0
# Wednesday, January 28, 2009

There were a few changes between ASP.NET MVC Beta and RC1 regarding list binding. For background on list binding, look at Phil Haack's excellent article. Here are the changes that I saw, some good, and some bad:

  • You no longer need to specify the ".index" hidden field. This is good, as it's one less hidden field to take care of.
  • Binding occurs automatically for lists of complex types, but you must have contiguous numbering of the elements, starting with zero. This means that you can no longer specify the index with things like key information. I'm not wild about this change.
  • In the Beta release, binding would only occur for properties of IList. I've been using LightSpeed lately, and that means my property looks like this: EntityCollection<FooType> FooProperty. EntityCollection supports IList, but because it wasn't truly an IList in the class declaration, the default binding didn't work. In the Beta release, I got around this by adding a mirrored property of IList<FooType> and then copying the data over to FooProperty in my controller method.
  • Nested property references, e.g. Foo.Bar, now get the resulting input id renamed to Foo_Bar. This makes it easier to work with jQuery selectors on these elements.

All in all, I'm really liking the RC1 release. I'm looking forward to the release!

Wednesday, January 28, 2009 6:04:53 PM (Central Standard Time, UTC-06:00)  #    Comments [1] -
ASP.NET
Monday, February 02, 2009 10:19:46 AM (Central Standard Time, UTC-06:00)
Hi, Dan.

I've been struggling with binding to collections, and the available articles aren't clear (to me). You seem to have more info, so I'd like to ask a couple of quick questions.

I've created a test application where, in a single page, I'll create/edit an invoice and lineitems, which is a reasonable scenario.

I can do this if I create simple classes, where Invoice.Items is exposed as List[Item], as Phil Haack describes.

I can't make it work if I'm using LINQ to SQL, because it appears that even in the RC Refresh the binder won't process Invoice.Items if Items is an EntitySet.

1. Is this correct, that EntitySet isn't bound?
2. You suggest exposing an IList[T] property that mirrors the EntitySet. How are you doing this?


I can supply you my code as needed, but didn't want to burden this post.

Thanks, and I'll certainly understand if you don't have time for this. Maybe you could point me to samples.

(couldn't use angles brackets for generics, so used squares)
Comments are closed.
Navigation
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Dan Miser
Sign In
Statistics
Total Posts: 375
This Year: 3
This Month: 0
This Week: 0
Comments: 654
Themes
Pick a theme:
All Content © 2012, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)