views:

359

answers:

1

hi everyone,

I know how pass viewdata into a user control which is like this

<% Html.RenderPartial("someUserControl.ascx", viewData); %>

This is what i want to do:

In the current situation i have events calendar and each section of my events calendar is a wired to a user control, so ideally when i pass a date value to my user control i want to get all the events that are going on on that paritcular day ( through some data base activity ).. so nothing is really coming from the actual controller..

Can someone please give me some idea on how to go about this one and what would be the best way of doing this..

Thanx

Owais F

+3  A: 

This is probably breaking the MVC paradigm. While it's perfectly possible to fetch data on the fly using a data context in the user control itself, to stick to MVC paradigm, it's suggested that you do the DB activity in the controller and pass it using ViewData to the page and the user control.

Mehrdad Afshari