I am going to try and word this as simplified as possible because the question I have is rather complex ( or so I think!!!).
Currently I have a variable tied to a repeater, which lists a group of profiles for various employees within the business.
Within the variable, I have a field "Job_Title" which contains both the sector they work in and the job title separated by a '/'. What I am trying to achieve is assigning a set DIV Class based upon the sector within the "Job_Title" string.
Now I can achieve this on a single profile by doing the following
DT_Control_Profile Pro =
db.DT_Control_Profiles
.SingleOrDefault(x => x.PageControlID == PageControl_ID);
if (Pro != null)
{
String[] cutsector = Pro.Job_Title.Split('/');
foreach (string s in cutsector)
{
if (s.Trim().ToUpper() == "WELL ENGINEERING")
{
DIV_SECOTR.Attributes.Add("class", "sectorcon conwelleng");
}
else if (s.Trim().ToUpper() == "RESEVOIR ENGINEERING")
{
DIV_SECOTR.Attributes.Add("class", "sectorcon conreseng");
}
else if (s.Trim().ToUpper() == "GEO SCIENCES")
{
DIV_SECOTR.Attributes.Add("class", "sectorcon congeoscie");
}
else if (s.Trim().ToUpper() == "FACILITES ENGINEERING")
{
DIV_SECOTR.Attributes.Add("class", "sectorcon confacilieng");
}
};
However I am struggling to conjure a way of achieving this using a variable, which pulls multiple profiles onto a page!
So far I have this:
var leaders = from x in db.DT_Control_Profiles
where x.FeatureProfile == true
&& x.DT_PageControl.DT_SitePage.VennID == codesnippets.VennID
select new
{
img = Path + x.ImageUrl,
x.Job_Title,
x.Name,
about = codesnippets.StringSize(x.Biography, 100),
link = "~/" + x.DT_PageControl.DT_SitePage.PageName,
};
I think that the solution would lie in a foreach loop but I have no idea where to begin!
Can anyone point me in the right direction??