public void loadContainerTree() { repositoryid = Convert.ToInt32(txtRepositoryID.Text); conn.Open(); SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM tblCabinets WHERE ParentID IS NULL AND repositoryID = '" + repositoryid + "'", conn); DataTable dt = new DataTable(); adapter.Fill(dt); RadTreeNode parentNode; foreach (DataRow dr in dt.Rows) { parentNode = ContainersTree.Nodes.Add(dr["cabinetName"].ToString()); PopulateTreeView(dr["cabinetID"].ToString(), parentNode); } ContainersTree.ExpandAll(); conn.Close(); } private void PopulateTreeView(string parentid, RadTreeNode parentNode) { SqlDataAdapter adapterchild = new SqlDataAdapter("SELECT * FROM tblCabinets WHERE ParentID = '" + parentid + "' AND repositoryID = '" + repositoryid + "'", conn); DataTable dtchild = new DataTable(); adapterchild.Fill(dtchild); foreach (DataRow dr in dtchild.Rows) { RadTreeNode childNode; if (parentNode == null) { childNode = ContainersTree.Nodes.Add(dr["cabinetName"].ToString()); } else { childNode = parentNode.Nodes.Add(dr["cabinetName"].ToString()); PopulateTreeView(dr["cabinetID"].ToString(), childNode); } getID = ContainersTree.Nodes.Add(dr["cabinetID"].ToString()); } }
SqlDataAdapter adapterchild = new SqlDataAdapter("SELECT * FROM tblCabinets WHERE ParentID = '" + parentid + "' AND repositoryID = '" + repositoryid + "'", conn);
SqlDataAdapter adapterchild = new SqlDataAdapter("SELECT * FROM tblCabinets WHERE ParentID = @ParentID AND repositoryID = @RepositoryID", conn); adapterchild.SelectCommand.Parameters.AddWithValue("@ParentID", parentid); adapterchild.SelectCommand.Parameters.AddWithValue("@RepositoryID", repositoryid);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)