MVC using webservice as Model - UIHint

I am creating an MVC project that uses the model from an external web service. I am using a telerik Grid for MVC, and want to use an EditorTemplate for one of the fields. Everything I have read so far has led me to believe that I need to decorate my Model with UIHint to enable a field for an Editor Template, but I do not have a model.

How should I achieve this? Preferably, I do not want to have to create a Model, but have I gone about this the wrong way? Should I always create a Model. Can anyone point me in the direction of some resources that will give me a good example? I am fairly new to development and also MVC.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I would create a view model that is filled with data from the Web service in the controller action, then pass the view model to the view personally. Then, you can decorate the property on your view model with the UIHint and any other goodies you may want for validation purposes.

However, if you just want to get through this as-is, you can change your view so it is told which Editor Template to use for that field/property. If you are rendering the entire model via Html.EditorForModel, you will have to change the view to render and editor for each property instead (unless you use a view model). Then, your individual Html.EditorFor or Html.Editor calls can be modified to specify which template to use.

<%= Html.EditorFor(model => model.SomeProperty, "MyTemplate") %>

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leedurrantAuthor Commented:
HI ventaur,

Thanks for the response. I have actually added a model anyway and it is now working. From your email, it does sound as though it is the best route to follow.
That is good to hear. I think you'll find that sometimes you may even want to combine some data from multiple models; perhaps from multiple web services. A view model lets you combine just the data you need for the view, regardless of how disparate the data's source may be.

Good luck!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.