public static String GenerateSubMenu(int parentID) { //Create and Instanciate our Table Adapter holding navigation details from the Robot Dataset RobotStandardTableAdapters.navigationmenuTableAdapter table = new RobotStandardTableAdapters.navigationmenuTableAdapter(); //Retrive values and set to the DataTable of Sub Menus DataTable navTable; //Create and Instanciate our Table Adapter holding navigation Authorization details from the Robot Dataset of tables RobotStandardTableAdapters.navigationmenu_authoriseTableAdapter authoriseAdapter = new RobotStandardTableAdapters.navigationmenu_authoriseTableAdapter(); DataTable authoriseTbl = authoriseAdapter.GetData(); if (authoriseTbl.Rows.Count > 0) { navTable = table.GetSubMenuAuthorized(parentID, GetAssignedPrivileges());// returns Authorised Menus } else { navTable = table.GetSubMenu(parentID);//All Active Menus } String menuHtml = "<ul>"; // Loop each Row of the ResultSet foreach (DataRow row in navTable.Rows) { menuHtml += "<li><a href=\"" + row["menu_url"].ToString() + "\"><b>" + row["menu_name"].ToString() + "</b></a>" + GenerateSubMenu(Convert.ToInt32(row["menuID"].ToString())) + "</li>"; } //return Sub menu String to the Parent/Caller menuHtml += "</ul>"; //return sub Menu to the Caller return menuHtml; }