Click here to Skip to main content
15,940,921 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,

I am making a registration page where i have follwoing columns.

Student Registration

Name :
Email :
Qualification :

I am binding qualification dropdodwnlist in a partial view.

But unable to call on StudentRegistration view.

I am using two model.
1. Student - Where all the regsitration will be stored.
2. Qualification - It is used to bind only qualification like MCA, MBA, CA etc

I am unable to call partial view with model

I am getting object refrence error in QualificationParitalView().

What I have tried:

Updated 18-Jul-17 20:55pm

1 solution

If you want to load it immedialty, then you use @Html.RenderPartial("_LoadView") or @Html.RenderAction("Load").

@Html.Partial("~/Views/Controller/View.cshtml", model)
Should do the trick.

If you want to pass through the (other) controller, you can use:

@Html.Action("action", "controller", parameters)
or any of the other overloads.
Share this answer
aditya2314 19-Jul-17 2:58am    
@Html.Partial("~/Views/Shared/_QualificationPartialView.cshtml", model)

I am getting error that "model doesnot exist in current context".
aditya2314 19-Jul-17 3:01am    
I am not able to use two mdels at the top in a view

@model LearnMvcCrudApplication.Models.Student
@model LearnMvcCrudApplication.Models.Qualification

Getting error that "Only one 'model' statement is allowed in a file."
Satya Prakash Swain 19-Jul-17 3:50am    
Model Student need to contain model Qualification. Then pass the model @Html.Partial("~/Views/Shared/_QualificationPartialView.cshtml", model.Qualification)
aditya2314 19-Jul-17 3:58am    
Thank you sir.

@Html.Partial("~/Views/Shared/_QualificationPartialView.cshtml", model.Qualification)

I am not getting Qualification Model in above line.
How model Student will contain model Qualification?
aditya2314 19-Jul-17 4:16am    
do i need to create a ViewModel which will contain both model Student and Qualification model?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900