Display products and product categories in single page

Brianna Shaffar asked on August 31, 2018 20:48

Sorry if this question is odd, I'm extremely new to using Kentico MVC.

Basically I'm working on a project for a donation site that is using two page types: Funds and Fund Categories. On the Kentico side, when a fund is created the user selects which category it belongs to from a dropdown of all categories.

On the front end we want to have a selection page that contains a dropdown with the categories, and then a section underneath that displays available funds that can be donated to. We want users to be able to sort through the funds by selecting a category from the dropdown, but I haven't been able to figure out a way to be able to use both in one page since they use separate models. I'm used to using Entity Framework, so I'm not really sure where to start for this. I am not using Kentico eCommerce currently.

If anyone can even give me a hint as to which direction to work towards, or a better way to get this working that would be awesome.

Thanks!

Recent Answers


Arun Kumar answered on September 4, 2018 08:02 (last edited on September 4, 2018 08:05)

You can create a custom web part for drop down selection and bind the data using code something like this and call it on OnPreRender event.

 var familyCategories = CategoryInfoProvider.GetChildCategories(familyParentId, siteId: SiteContext.CurrentSiteID);
    var familyCatList = familyCategories.ToList();
    var defaultFamilyItem = new CategoryInfo();
    defaultFamilyItem.CategoryDisplayName = "Product Family";
    familyCatList.Insert(0, defaultFamilyItem);

    drpFamily.DataSource = familyCatList;
    drpFamily.DataTextField = "CategoryDisplayName";
    drpFamily.DataValueField = "CategoryID";
    drpFamily.DataBind();

You can follow this link for help. Place this custom filter web part on the page. Below that add repeater web part and add this filter name in Filter name property of repeater.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.