I bring data from my database, what I want to do is bring all this data to my html, the problem is that for those who have "1" in the field level a tag is created li , that's what I do with this piece of code:
HtmlGenericControl li = new HtmlGenericControl("li");
if(nivel=="1")
{
//el 'tree2' es el id de una etiqueta <ul> en el html, que esta con un runat="server"
tree2.Controls.Add(li);
}
The problem is in the following condition, for records that have "2" in the level field the ul tag is created inside of the li tag that you create in the first condition. I try to do with this same code:
if(nivel=="2")
{
HtmlGenericControl ul = new HtmlGenericControl("ul");
li.Controls.Add(ul);
}
When I do this, records with the value "2" in the level field do not come out, unless instead of putting li.Controls.Add (ul) tree2.Controls.Add (ul)
I need a way to say, for those who have level="1" that this is done, and for those who have level="2" to be done this within what was done for the first condition.