VB Code:
void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e) { SqlConnection cn = new SqlConnection(Cnstring); string SqlString = "Select CHR_ROOT, CHR_DESCRIPCION from SIS_MATRIZ_MENU Order by chr_root"; SqlCommand cmd = new SqlCommand(SqlString, cn); cn.Open(); using (cn) { SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { TreeNode newNode = new TreeNode(); newNode.PopulateOnDemand = true; newNode.Text = reader["CHR_DESCRIPCION"].ToString(); newNode.Value = reader["CHR_ROOT"].ToString(); e.Node.ChildNodes.Add(newNode); } } }
This code is to populate a treeview.
I want to:
1. Run this code as soon as the page is loaded or
2. Run the TreeView1_TreeNodePopulate from anywhere
How can i do this


Reply With Quote
