I'm using the WebDataTree and when I'm creating programatically the structure I'm also creating custom attributes for the nodes, the first time the page is renderered the attributes are rendered too, but when a postback occur, the attributes are missing.
I'm not overriding, or deleting the attributes, they just dissapear.
Is there a solution, or maybe I'm doing something wrong?
Thanks in advance for the help.
This is what I have in the page load:
if (!IsPostBack) {
foreach (var nodeStructure in ListStructure)
{
DataTreeNode nodo = new DataTreeNode();
nodo.Attributes.Add("Estructura", nodeStructure.Id.ToString());
nodo.Text = nodeStructure.Nombre;
LoadHierarchy(nodo, nodeStructure);
tree.Nodes.Add(nodo); }
var nodes = from DataTreeNode nodo in tree.AllNodes where !string.IsNullOrEmpty(nodo.Key) select nodo; int order = 1; foreach (DataTreeNode nodo in nodes) { nodo.Attributes.Add("Order", order.ToString()); order++; }
}
And this is the recursive method:
private void LoadHierarchy(DataTreeNode nodoPadre, ModuloContenido contenidoPadre) { foreach (var nodoContenidoHijo in contenidoPadre.ColModuloContenidoHijos) { DataTreeNode nodoHijo = new DataTreeNode(); nodoHijo.Attributes.Add("Estructura", nodoContenidoHijo.IdModuloContenido.ToString()); nodoHijo.Text = nodoContenidoHijo.Nombre; ArmarJerarquia(nodoHijo, nodoContenidoHijo); nodoPadre.Nodes.Add(nodoHijo); } }
After a click in the node, the attributes are missing, but not all of them, the "Order" attribute still remains.
Hello,
If you can provide me with a sample that demonstrates the behavior you are seeing then I can look into why the attributes are missing after postback.