salve a tutti, vorrei chiedervi una cosa
Ho una treeview che creo dinamicamente ed di stato iniziale è chiusa
poi apri i vari nodi quando clicco sul nodo mi si visualizza sulla dx un listview
ma contemporaneamente mi si richiude la treeview invece vorrei:
1.che rimanesse aperta su ramo che ho selezionato
come posso fare? grazie a tutti
/* CODICE */
Codice PHP:PADRI
protected void fillTreeView()
{
int IDCat = 0;
string Query = "SELECT ID,Nome From CatFoto WHERE IDPadre is null";
TrvCatFoto.Nodes.Clear();
OleDbCommand MyCommand = ClassFunzioni.MyCommand(Query);
OleDbDataReader MyReader = MyCommand.ExecuteReader();
while (MyReader.Read())
{
TreeNode tn = new TreeNode();
tn.Text = MyReader["Nome"].ToString();
IDCat = Convert.ToInt32(MyReader["ID"].ToString());
tn.Value = MyReader["ID"].ToString();
tn.CollapseAll();
TrvCatFoto.Nodes.Add(tn);
AddChildNode(IDCat, tn);
}
MyReader.Close();
ClassFunzioni.ChiudiConnessione();
}
FIGLI
protected void AddChildNode(int IDPadre, TreeNode tnPadre)
{
int IDCatFiglio = 0;
string Query = "SELECT ID,Nome From CatFoto WHERE IDPadre =" + IDPadre + " AND isFoto = false ORDER BY Nome ASC";
OleDbCommand MyCommand = ClassFunzioni.MyCommand(Query);
OleDbDataReader MyReader = MyCommand.ExecuteReader();
while (MyReader.Read())
{
TreeNode tnFiglio = new TreeNode();
tnFiglio.Text = MyReader["Nome"].ToString();
IDCatFiglio = Convert.ToInt32(MyReader["ID"].ToString());
tnFiglio.Value = MyReader["ID"].ToString();
tnPadre.ChildNodes.Add(tnFiglio);
/* Controllo se il figlio dei figli */
AddChildNode(IDCatFiglio, tnFiglio);
}
MyCommand.Dispose();
ClassFunzioni.ChiudiConnessione();
}

Rispondi quotando