I have this Excel File which I tried to upload. It has Parent Category
Model
Code
public partial class CategoryLevelCode
{Code
public long CategoryID { get; set; }Code
public string CategoryName { get; set; }Code
public string OPTION_VALUE { get; set; }Code
public Nullable ParentID { get; set; }Code
public Nullable ParentID1 { get; set; }Code
public Nullable ParentID2 { get; set; }Data sample
Controller
The code ihave written so far is in the controller.
Without clicking twice to upload, it will retrieve the data it has saved to perform the following manipluations.
- From the Excel, Where Category Code is equal to Parent Category, it means its a child of the corresponding parent. So, it will save the CategoryID of its parent as its ParentID
- From the Excel, where Category Name is Null, it means its a root and has no parent
- ParentID1 is the Level - It can get to level N
- ParentID of the Root Category(Level 1) will be set to 0
- ParentID of the Child Category will be the CategoryID of the direct parent
- Note that CategoryID is System Generated (auto-increment)
Please how do I achieve this using the same controller, and also with the same instance of upload.

Nilesh ShahRank #42 · 34.2K reputationPosted Dec 4, 2017, 4:54 AM EST
mike idowuRank #4,104 · 365 reputationPosted Dec 4, 2017, 5:12 AM EST
mike idowuRank #4,104 · 365 reputationPosted Dec 4, 2017, 5:14 AM EST