issue in ObservableCollection

Posted by prince23 on Stack Overflow See other posts from Stack Overflow or by prince23
Published on 2010-05-31T10:06:57Z Indexed on 2010/05/31 10:13 UTC
Read the original article Hit count: 568

Filed under:

hi, i have an lsit with these data

i have a class called information.cs with these properties name,school, parent

ex data

 name    school  parent

kumar      fes         All

manju      fes         kumar

anu         frank       kumar

anitha      jss          All

rohit       frank       manju

anill        vijaya      manju

vani         jss          kumar

soumya   jss           kumar

madhu     jss          rohit

 shiva       jss          rohit

vanitha       jss          anitha
 anu      jss          anitha

now taking this as an input i wanted the output to be formated with a Hierarchical data when parent is all means it is the topmost level kumar fes All. what i need to do here is i need to create an object[0] and then check in list whether kumar exists as a parent in the list if it exista then add those items as under the object[0] as a parent

i need  to create one more oject under
**manju      fes         kumar

anu         frank       kumar**

if you see this class file its shows how data is formatted. public class SampleProjectData { public static ObservableCollection GetSampleData() { DateTime dtS = DateTime.Now;

            ObservableCollection<Product> teams = new ObservableCollection<Product>();
            teams.Add(new Product() { PDName = "Product1", OverallStartTime = dtS, OverallEndTime = dtS + TimeSpan.FromDays(3),  });


            Project emp = new Project() { PName = "Project1", OverallStartTime = dtS + TimeSpan.FromDays(1), OverallEndTime = dtS + TimeSpan.FromDays(6)  };
            emp.Tasks.Add(new Task() { StartTime = dtS, EndTime = dtS + TimeSpan.FromDays(2), TaskName = "John's Task 3" });
            emp.Tasks.Add(new Task() { StartTime = dtS + TimeSpan.FromDays(3), EndTime = dtS + TimeSpan.FromDays(4), TaskName = "John's Task 2" });
            teams[0].Projects.Add(emp);
}
return teams;
}

© Stack Overflow or respective owner

Related posts about c#