Hii C#Guys,
i need to bind menus and submenus dynamically in Expandable listview, im getting data from API's in this format
- [
- {
- "applicationid": 24347,
- "applicationname": "Timetable Staff",
- "ParentApplicationId": 24444,
- "pagelink": "~/Web/Reports/TimeTableStaff.aspx",
- "PageName": "Reports/TimeTableStaff",
- "sortorder": null,
- "IconCD": null
- },
- {
- "applicationid": 24875,
- "applicationname": "Question Bank-Scholastic",
- "ParentApplicationId": 24438,
- "pagelink": "~/Web/QuestionBank/SearchQuestions.aspx",
- "PageName": "QuestionBank/Search",
- "sortorder": null,
- "IconCD": null
- },
- {
- "applicationid": 24879,
- "applicationname": "Tests-Scholastic",
- "ParentApplicationId": 24438,
- "pagelink": "~/Web/QuestionBank/QuestionPaperSearch.aspx",
- "PageName": "TestsScholastic/Search",
- "sortorder": null,
- "IconCD": null
- },
- {
- "applicationid": 34113,
- "applicationname": "Staff Leave Management",
- "ParentApplicationId": 24439,
- "pagelink": "~/Web/LeaveManagement/LeaveManagementStaffList.aspx",
- "PageName": "LeaveManagementStaff/List",
- "sortorder": null,
- "IconCD": null
- },
- {
- "applicationid": 24276,
- "applicationname": "Subjects",
- "ParentApplicationId": 24438,
- "pagelink": "~/Web/Course/CourseSearch.aspx",
- "PageName": "Course/Search",
- "sortorder": 1,
- "IconCD": null
- },}
im using foreach loop to add all prent in one list
- var response = SisApi.Get("Auth/getmenu", out issucsesParam, UserId);
- Person pobj = new Person();
- var person = new Person { applicationname = "", ParentApplicationId = "", applicationid = "" };
- var menu2 = JsonConvert.DeserializeObject
- >(response);
- foreach (var n in menu2)
- {
- if (n.ParentApplicationId == null)
- {
- ParentnodeNames.Add(n.applicationname);
- }
- }
if parentnodes list have 20 records say Admin, Management, Library i'm statically creating that many List like ListAdmin, ListManagement to add relevent child records
below
- foreach (var r in menu2)
- {
- if (r.ParentApplicationId == "24439" || r.applicationname == "Admin")
- {
- AdminList.Add(r.applicationname);
- }
- if (r.ParentApplicationId == "24443" || r.applicationname == "Management")
- {
- ManagementList.Add(r.applicationname);
- }
- if (r.ParentApplicationId == "24438" || r.applicationname == "Academics")
- {
- AcademicsList.Add(r.applicationname);
- }
- }
finally im adding all list in Dicationary
- Dictionary<string, List<string>> childdata=new Dictionary<string,List<string>>();
- entnodeNames.Contains("Admin"))
- childdata.Add(ParentnodeNames[0], AdminList);
- if (ParentnodeNames.Contains("Management"))
- childdata.Add(ParentnodeNames[1], ManagementList);
- if (ParentnodeNames.Contains("Academics"))
- childdata.Add(ParentnodeNames[2], AcademicsList);
here this my logic working fine for the same data if someone add more record in database my logic will fail i need to again modify my code and creating lists, please can anyone tell me the to add these menus dynamically
for reference purpose please see this demo
http://www.appliedcodelog.com/2016/06/expandablelistview-in-xamarin-android.html
thanks :)

Replies
Know the answer? Post it — somebody with the same question will find it here.