The conversion should be contained in a class library used behind the
scenes, IMO. As much as possible, you should massage the data formats prior
to binding.
You could, theorhetically, use the controller, as it is code. The problem
here is you are muddying the waters and make the controller into a
controller-converter. As far as what should call the converter, this is on
the controller level, not the view. A view is merely a tool to display data
to the end user, when used correctly.
One other option is to supe up your Model classes, especially with Preview 3
(and later? - nothing later released yet).
My favorite patterns, at least for now, is to alter the pages so they use
ViewPage<Tinstead of ViewPage. This works best if T is a bit of a proxy
class that binds the model and adds some helpers. Do not overblow this class
with funcationality. It should be a data object, not a behavioral object.
Using this pattern, you then pass an object (T) to the page with your model.
I have not thought this through completely (I am thinking and writing), but
I could see creating different routines that serve up the model in
differernt formats, CSV, list, standard data using IEnumerable, etc. I will
have to think this pattern through a bit before giving a final seal of
approval, as this may be a bit too much behavior. Right now, I am leaning
this direction, at least for a simple implentation.
Longer term, you could set up an interface T to adhere to for that page, but
that is probably overkill. It would be fun, as a geek, however. :-)
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss
or just read it:
http://gregorybeamer.spaces.live.com/
********************************************
| Think outside the box! |
********************************************
"shapper" <md*****@gmail.comwrote in message
news:76**********************************@m45g2000 hsb.googlegroups.com...
Hello,
I am using ASP.NET MVC and I am running into a problem.
I have a List Of MyClass which is a property of my controller
ViewData.
In the View I have a form where I need to display the List in the CSV
format.
When I submit the form I need to convert that CSV data to a list
before I save it to the database using Linq.
The View also displays the same data in an ordered list. And there are
other view which do the same.
How should I implement this and where to make the conversions? In the
View? In the Controller?
Thanks,
Miguel