0

I am making a site for entering metadata. On the first tab (CSS tabs) I have few dropdowns and after you make the choices, the second tab is unlocked. first tab

Right now the second tab is empty, and the contend that is supposed to go there, I have put it in another view. It looks like this. second tab

Now, what I want to achieve is - when I open the second tab the view in the second picture should be shown, loaded as @Html.Partial. So, after I make the choices in the first tab, select one of the items in the list in the second tab, and written some text in the editor, all of that should be saved to the DB.

Here is the controller action for the list in the second tab:

    public ActionResult asdf()
    {
        List<SIMS_Test> all = new List<SIMS_Test>();
        using (UsersContext dc = new UsersContext())
        {
            var LanguageID = Thread.CurrentThread.CurrentUICulture.Name;

            if (LanguageID == "en-US")
            {
                all = dc.SIMS_Test.Where(s => s.LanguageID == "en-US").OrderBy(a => a.ID).ToList();
            }
            else
            {
                all = dc.SIMS_Test.Where(s => s.LanguageID == "mk-MK").OrderBy(a => a.ID).ToList();
            }
        }
        return View(all);
    }

The problem is the partial view cannot be loaded inside the main view because they use different models in the views:

@model MvcApplication20.Models.MetapodatociModel

and

@model List<MvcApplication20.Models.SIMS_Test>

Can this be done this way, but also, can it take the values of the partial view, give them to the controller action of the main view so that all this can be saved in the DB?


Edit: Here are the models:

public class MetapodatociModel
{
    [Required(AllowEmptyStrings = false, ErrorMessageResourceType = typeof(Resources.Home), ErrorMessageResourceName = "StringDD1Empty")]
    public string Domen { get; set; }
    [Required(AllowEmptyStrings = false, ErrorMessageResourceType = typeof(Resources.Home), ErrorMessageResourceName = "StringDD2Empty")]
    public string Istrazuvanje { get; set; }
    [Required(AllowEmptyStrings = false, ErrorMessageResourceType = typeof(Resources.Home), ErrorMessageResourceName = "StringDD3Empty")]
    public string Frekvencija { get; set; }
    [Required(AllowEmptyStrings = false, ErrorMessageResourceType = typeof(Resources.Home), ErrorMessageResourceName = "StringDD4Empty")]
    public string Period { get; set; }
    [Required(AllowEmptyStrings = false, ErrorMessageResourceType = typeof(Resources.Home), ErrorMessageResourceName = "StringDD5Empty")]
    public string Godina { get; set; }
    [AllowHtml]
    [UIHint("tinymce_full")]
    public string TestPole { get; set; }
}

[Table("SIMS_Test", Schema = "sims")]
public class SIMS_Test
{
    [Key, Column(Order = 0)]
    public int ID { get; set; }
    public string SIMSCode { get; set; }
    public string Inheritance { get; set; }
    [Key, Column(Order = 1)]
    public string LanguageID { get; set; }
    public int LevelId { get; set; }
    public int QualityId { get; set; }
    public string ConceptName { get; set; }
    public string ConceptCode { get; set; }
    public string Descriptions { get; set; }
    public string Representation { get; set; }
    public string ESSGuidelines { get; set; }
    public int? OrderId { get; set; }
}
3
  • You need a view model containing properties for both models Commented Jul 25, 2017 at 23:41
  • But what about the thing that one of them is used the normal way, and the other one is used as a List<> ? Commented Jul 27, 2017 at 11:41
  • That makes no difference Commented Jul 27, 2017 at 11:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.