public void tvBind() { try { tvGroups.Nodes.Clear(); dtGroups = Groups.GetGroups(whereCondition); if (dtGroups != null && dtGroups.Rows.Count > 0) { TreeNode tnParent = new TreeNode("Groups", "Groups"); tvGroups.Nodes.Add(tnParent); tnParent.SelectAction = TreeNodeSelectAction.Expand; foreach (DataRow GroupRow in dtGroups.Rows) { string child = GroupRow["GroupName"].ToString(); if (!string.IsNullOrEmpty(GroupRow["SecurityGroupApp"].ToString().Trim())) { child = child + " - " + GroupRow["SecurityGroupApp"].ToString(); } TreeNode tnChild = new TreeNode(child, GroupRow["ID"].ToString()); tnParent.ChildNodes.Add(tnChild); tnChild.SelectAction = TreeNodeSelectAction.SelectExpand; } if (whereCondition != "") { lblSearch.Text = dtGroups.Rows.Count.ToString().Trim() + " records found"; } } } catch (Exception ex) { } }