2
I have a Treeview component, and a structure in the database that already has in the table directories the subdirectories. has a field called director_parent_guid, if it is null it is because it is root, if not, it is some other directory id. So I have the following structure:
Method that returns directories: waiting for a parameter that will list only the directories with Parent guid equal to string passed:
internal List<Diretorio> GetSubDiretorio(String termo)
{
using (var ctx = new TESTEntities())
{
var diretorios = (
from dir in ctx.DIRETORIO
where dir.DIRETORIO_PARENT_GUID == termo
select new Diretorio()
{
DIRETORIO_GUID = dir.DIRETORIO_GUID,
XDIRETORIO = dir.XDIRETORIO,
REFERENCIA = dir.REFERENCIA
}
).ToList();
return diretorios;
}
}
Filling in the treeview I tried:
public void CriarTreeView()
{
var raiz = DiretorioController.GetInstance().GetSubDiretorio("");
foreach (var diretorio in raiz )
{
node = new TreeNode(diretorio.XDIRETORIO);
node.ImageUrl = "~/asstes/img/directory.png";
TreeView1.Nodes.Add(node);
foreach (var subDiretorio in DiretorioController.GetInstance().GetSubDiretorio())
{
TreeNode nodeSub = new TreeNode(subDiretorio.XDIRETORIO);
nodeSub.ImageUrl = "~/asstes/img/directory.png";
node.ChildNodes.Add(nodeSub);
}
}
}
This way it is working directories and Subdirectories, however it is manual, if I create a directory inside a subdirectory it does not list, I could not apply the correct logic yet. What it would look like to list the Ubdirectories correctly?
So it’s creating the third directory, but if I select the first again, it creates below the second always.
– War Lock
So now the I problem is another, consider asking a new question.
– Tobias Mesquita
It worked out, thanks
– War Lock