Vote count:
0
i am working with mvc4 and c#
i have a sql table like,
Id Name ParentCategoryId
----------------------------------------
1 A Null
2 B Null
3 C 1
4 D 1
5 E 4
6 F 3
I want List this in my razor view Like,
Category model
public int Id { get; private set; }
public string Name { get; set; }
public int ParentId { get; private set; }
And in the controller,
public ActionResult Index(int category=0)
{
// got the root categories(A, B)
var Root = new Categories().ToList();
//get childs of particular category
Category cat = new Category(id);
List<Category> child = new Categories().ToList(cat);
return View();
}
How can i get all the category in the database in a single action when index page loading
asked 36 secs ago
Generating a tree from sql in mvc4
Aucun commentaire:
Enregistrer un commentaire