public static string GenerateColumnHtml(string name, StructDivision m, List <StructDivision> Model, List <Employee> employes, ref int index, string refId) { string valuePrefix = string.Format("{0}[{1}]", name, index); var sb = new StringBuilder(); string trName = string.Format("tr_{0}{1}", name, index); sb.AppendFormat("<tr Id='{0}' {1}>", trName, string.IsNullOrEmpty(refId) ? string.Empty : string.Format("class='child-of-{0}'", refId)); sb.AppendFormat("<input type='hidden' name='{0}.Id' value='{1}'></input>", valuePrefix, m.Id); sb.AppendFormat("<input type='hidden' name='{0}.ParentId' value='{1}'></input>", valuePrefix, m.ParentId); sb.AppendFormat("<td class='columnTree'><b>{0}</b></td>", m.Name); sb.AppendFormat("<td></td>"); sb.Append("</tr>"); foreach (var item in employes.Where(c => c.StructDivisionId == m.Id)) { index++; sb.Append(GenerateColumnHtml(name, item, ref index, trName)); } foreach (var item in Model.Where(c => c.ParentId == m.Id)) { index++; sb.Append(GenerateColumnHtml(name, item, Model, employes, ref index, trName)); } return(sb.ToString()); }
public static string GenerateColumnHtml(string name, StructDivision m, List<StructDivision> Model, List<Employee> employes, ref int index, string refId) { string valuePrefix = string.Format("{0}[{1}]", name, index); var sb = new StringBuilder(); string trName = string.Format("tr_{0}{1}", name, index); sb.AppendFormat("<tr Id='{0}' {1}>", trName, string.IsNullOrEmpty(refId) ? string.Empty : string.Format("class='child-of-{0}'", refId)); sb.AppendFormat("<input type='hidden' name='{0}.Id' value='{1}'></input>", valuePrefix, m.Id); sb.AppendFormat("<input type='hidden' name='{0}.ParentId' value='{1}'></input>", valuePrefix, m.ParentId); sb.AppendFormat("<td class='columnTree'><b>{0}</b></td>", m.Name); sb.AppendFormat("<td></td>"); sb.Append("</tr>"); foreach (var item in employes.Where(c => c.StructDivisionId == m.Id)) { index++; sb.Append(GenerateColumnHtml(name, item, ref index, trName)); } foreach (var item in Model.Where(c => c.ParentId == m.Id)) { index++; sb.Append(GenerateColumnHtml(name, item, Model, employes, ref index, trName)); } return sb.ToString(); }