Chetan RanpariyaRank #1,852 · 801 reputationPosted Jan 6, 2017, 7:13 PM EST
✓ Accepted answer+2
Hi Abhilash,
Thanks for sharing the code.
The problem is the place you put your Children partial view.
If you want user @Html.Partial then the partial view must at the same place where other views of that controller are added. In your case you should create partial view "Children.cshtml" under views -> Home folder. as displayed in below image.
I hope this will solve your problem.
Please do some ground search and try to solve the problem before just posting it on the forum. This will save time.
Chetan RanpariyaRank #1,852 · 801 reputationPosted Jan 6, 2017, 2:46 PM EST
+2
Hi Abhilash,
"Partial view "Children" was not found" . This error occurs because the view "Children" could not be found in your MVC project.
The error says itself Abhilash.
Make sure that you are calling @html.Partial with correct viewname and model parameter and also make sure that partial view is under correct controller.
Can you please share the code of your MVC application? If not can you put the entire exception details?
Brijesh RathorRank #7,391 · 242 reputationPosted Jan 6, 2017, 5:15 AM EST
0
first u include jstree js and min in your project then in view
Select All
@foreach (var stateregions in Model)
{
if (stateregions.StateDetails.IsSelected)
{
@stateregions.StateDetails.Value
@foreach (var region in stateregions.Regions)
{
if (region.IsSelected)
{
@region.Value
}
else
{
@region.Value
}
}
}
if (stateregions.StateDetails.IsSelected != true)
{
@stateregions.StateDetails.Value
@foreach (var region in stateregions.Regions)
{
if (region.IsSelected)
{
@region.Value
}
else
{
@region.Value
}
}
}
}
do like this pass the models as like format hear i passed state region , region is related to states
hope it will help u.
just do it .
i already implement this. so u start .if any issue come then ask me i will solve no problem
Thnaks
Brijesh
0
Abhilash J ARank #1,243 · 1.4K reputationPosted Jan 6, 2017, 5:19 AM EST
0
Hello Brijesh Rathor,
Thank you... 'feeling inspiring' . I will try...
0
Abhilash J ARank #1,243 · 1.4K reputationPosted Jan 6, 2017, 8:00 AM EST
0
Hello Brijesh,
I have used jsTree. This is sql table. I have attached script file here. PFA. I have done this task by follow this url: http://techiesweb.net/2012/09/21/asp-net-mvc3-tree-view-with-jstree.html
But error occurred as shown below.
After I have added .edmx file. then the model class,
public partial class Employee
{
publicint ID { get; set; }
publicstring Name { get; set; }
publicstring SubName { get; set; }
public Nullable<int> ManagerID { get; set; }
public IList Employees { get; set; }
public Employee()
{
Employees = new List();
}
}
publicclass GetDetails
{
publicstatic List GetAllUsers()
{
DMSys_DBEntities db = new DMSys_DBEntities();
return db.Employees.ToList();
}
}
Then I have created controller,
public ActionResult Index()
{
List userList = new List();
userList = GetDetails.GetAllUsers();
var president = userList.Where(x => x.ManagerID == 0).FirstOrDefault();
SetChildren(president, userList);
return View(president);
}
privatevoid SetChildren(Employee model, List userList)
{
var childs = userList.Where(x => x.ManagerID == model.ID).ToList();
if (childs.Count > 0)
{
foreach (var child in childs)
{
//SetChildren(childs, userList);
//model.Employees.Add(childs);
userList.Add(child);
}
}
}
then, created view page
@model MvcApplication6.Models.Employee
<scriptsrc="~/Scripts/jstree.js">script>
<linkhref="~/style.css"rel="stylesheet"/>
<h2>Organization Treeh2>
<divid="divtree">
<ulid="tree">
<li>
<ahref="0"class="usr">
@Model.Name
a>
@Html.Partial("Children", Model)
li>
ul>
div>
<scripttype="text/javascript">
$(function () {
$('#divtree').jstree();
})
script>
I have created Partial view,
@model MvcApplication6.Models.Employee
@{
ViewBag.Title = "Children";
}
@foreach (var item in Model.Employees)
{
<ul>
@if (item != null)
{
<li>
<ahref="0"class="usr">@item.Namea>
@if (item.Employees.Count > 0)
{
@Html.Partial("Children", item)
}
li>
}
ul>
}
But, after run the application show this error.
Please help me.
0
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Jan 6, 2017, 9:25 AM EST
Chetan RanpariyaRank #1,852 · 801 reputationPosted Jan 6, 2017, 7:13 PM EST
Chetan RanpariyaRank #1,852 · 801 reputationPosted Jan 6, 2017, 2:46 PM EST
Chetan RanpariyaRank #1,852 · 801 reputationPosted Jan 6, 2017, 3:42 AM EST
Brijesh RathorRank #7,391 · 242 reputationPosted Jan 6, 2017, 4:30 AM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Jan 6, 2017, 5:05 AM EST
Brijesh RathorRank #7,391 · 242 reputationPosted Jan 6, 2017, 5:15 AM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Jan 6, 2017, 5:19 AM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Jan 6, 2017, 8:00 AM EST
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Jan 6, 2017, 9:25 AM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Jan 6, 2017, 9:37 AM EST
Chetan RanpariyaRank #1,852 · 801 reputationPosted Jan 6, 2017, 4:43 PM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Jan 6, 2017, 4:48 PM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Jan 6, 2017, 9:04 PM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts