I have to use a partial view macro inside a content page.The partial view shows data from database.Could please suggest me a solution for this requirement
var db = ApplicationContext.Current.DatabaseContext.Database;
// Fetch a collection of contacts from the db.
var listOfContacs = db.Fetch<Contact>(new Sql().Select("*").From("myContactsTable"));
ok you can make DB call in partial view as Alex gave like below.
@{
var db = ApplicationContext.Current.DatabaseContext.Database;
// Fetch a collection of contacts from the db.
var listOfContacs = db.Fetch<Contact>(new Sql().Select("*").From("myContactsTable"));
}
PartialView Macro in content page
I have to use a partial view macro inside a content page.The partial view shows data from database.Could please suggest me a solution for this requirement
Hi Deepa,
You need to make that parial view under
\Views\MacroPartials
folder.Then you will we able to add that partial view in Macro.
After that you can easily call macro inside template.
Hope it will help.
Regards,
Urvish Mandaliya
Hi Deepa,
You can use Umbraco database context class, like here http://creativewebspecialist.co.uk/2013/07/16/umbraco-petapoco-to-store-blog-comments/
Thanks, Alex
I need to show datas from database in that partial view.
ok you can make DB call in partial view as Alex gave like below.
Regards,
Urvish Mandaliya
is working on a reply...