Dear All I would like to have one view in which I will show listing , I will add new record , I will update and delete record only one signle view I want to show all of them in one view , is there any example for asp.net core mvc ?
Loading
Dear All I would like to have one view in which I will show listing , I will add new record , I will update and delete record only one signle view I want to show all of them in one view , is there any example for asp.net core mvc ?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh KumarPosted Aug 6, 2024, 4:44 AM
Hey Mark,
Please use this example,
Create model for student, Course and StudentCourse mapper calss and view model
Create Controller :
Create View :
Edit View
Mark TaborPosted Aug 4, 2024, 3:53 PM
The issue is i am using viewmodel and let say I have two models student and courses as below
public class student
{
public int id {get;set;}
public string name{get;set;}
}
public class coruse
{
public int id {get;set;}
public string name{get;set;}
}
My ViewModel is like below
public class MyVM
{
public student stu{get;set;}
public course cur{get;set;}
}
my index view need List and List and my create view does not need list so if we put all of them in one view how I adjust my model like for create it shoud not be list and for lising it should be list . to it but when I render the view it says the main view in which I have parital view does not have Ieneumerable or list so the partial view should have the same model as the main view have. thats the problem any example here
Abhishek Yadav yes I have a partial view and for listing and I give model as List
Tahir AnsariPosted Aug 4, 2024, 1:49 PM
let’s assume you have a
ControllerProductmodelNext, create a controller to handle the logic.
ViewNow, create a view to handle all actions in a single page.
Index.cshtml
Abhishek YadavPosted Aug 4, 2024, 11:42 AM
Model: Defines the structure of your data.
Controller: Handles the CRUD operations.
Indexreturns the view,Addadds a new item,Updateupdates an existing item, andDeleteremoves an item.Views:
JavaScript: Uses jQuery to send AJAX requests to the server to perform CRUD operations and update the view accordingly.
This approach provides a single-page interface for managing records, improving the user experience by avoiding full page reloads.