471,310 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

NET MVC

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
1 1172
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.

Similar topics

3 posts views Thread by William C. White | last post: by
2 posts views Thread by Albert Ahtenberg | last post: by
3 posts views Thread by James | last post: by
reply views Thread by Ollivier Robert | last post: by
1 post views Thread by Richard Galli | last post: by
4 posts views Thread by Albert Ahtenberg | last post: by
1 post views Thread by inderjit S Gabrie | last post: by
2 posts views Thread by Jack | last post: by
3 posts views Thread by Sandwick | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.