By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,667 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,667 IT Pros & Developers. It's quick & easy.

NET MVC

P: n/a
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
Jul 7 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Mon, 07 Jul 2008 06:59:21 -0700, shapper <md*****@gmail.comwrote:
[...]
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.

[...]
How should I implement this and where to make the conversions? In the
View? In the Controller?
IMHO, there's no "right answer" to the question. Personally, I would
generally make the view responsible for all data conversions, inasmuch as
they are just different ways of looking at the model. But to some extent,
MVC is just something to use as your design guide. If in your situation
it works better or seems more appropriate for the controller part of your
code to handle data conversion of that nature, by all means do it that way.

A design pattern should be something that aids you. If it constrains you,
it should only do so in a beneficial way. If you find a design pattern
constraining you in a way that seems only detrimental, and you feel that
you can prove to yourself that it _is_ only detrimental, then ignore that
constraint.

If nothing else, you may find later that you were wrong, and you'll learn
something about why the constraint is important. And it could turn out
that you were right, in which case you'll have avoided a lot of headaches
trying to comply with an arbitrary, useless constraint. :)

Pete
Jul 7 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.