private static void LoadZoneItemsOrderByName(ListItemCollection lstZones, ListItem curItem) { int level = Convert.ToInt32(curItem.Attributes["Level"]); level += 1; int curZoneID = ConvertUtility.ToInt32(curItem.Value); DataTable dtChildItems = ZoneDB.GetByParentIDOrderByName(curZoneID); foreach (DataRow row in dtChildItems.Rows) { ListItem childItem = new ListItem(); childItem.Text = MiscUtility.StringIndent(level) + row["Zone_Name"]; childItem.Value = row["Zone_ID"].ToString(); childItem.Attributes.Add("Level", level.ToString()); lstZones.Add(childItem); LoadZoneItems(lstZones, childItem); } }
private static void LoadCmdItem(ListItemCollection lst, ListItem curItem, DataTable dtCommands, string fieldKey, string fieldName, string fieldParentID, string sortBy) { int level = Convert.ToInt32(curItem.Attributes["Level"]); level += 1; int curID = Convert.ToInt32(curItem.Value); DataRow[] drChilds = dtCommands.Select(fieldParentID + " = " + curID); foreach (DataRow row in drChilds) { ListItem childItem = new ListItem(); childItem.Text = MiscUtility.StringIndent(level) + row[fieldName].ToString(); childItem.Value = row[fieldKey].ToString(); childItem.Attributes.Add("Level", level.ToString()); lst.Add(childItem); LoadCmdItem(lst, childItem, dtCommands, fieldKey, fieldName, fieldParentID, sortBy); } }