Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6872729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:57:58+00:00 2026-05-27T03:57:58+00:00

I am going to try and word this as simplified as possible because the

  • 0

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??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:57:59+00:00Added an answer on May 27, 2026 at 3:57 am

    You should be able to call a function inside your linq query. Create a function like this:

    public static string GetHtmlClass(DT_Control_Profile Pro)
    {
        String result = "";
        String[] cutsector = Pro.Job_Title.Split('/');
        foreach (string s in cutsector)
        {
            if (s.Trim().ToUpper() == "WELL ENGINEERING")
            {
                result += "sectorcon conwelleng ";
            }
            else if (s.Trim().ToUpper() == "RESEVOIR ENGINEERING")
            {
                result += "sectorcon conreseng ";
            }
            else if (s.Trim().ToUpper() == "GEO SCIENCES")
            {
                result += "sectorcon congeoscie ";
            }
            else if (s.Trim().ToUpper() == "FACILITES ENGINEERING")
            {
                result += "sectorcon confacilieng ";
            }
        }
    }
    

    After which your query should work like 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,
                      class = GetHtmlClass(x)
                  };
    

    That should get you the class right in your query result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I'm going to try to make this more clear because my last question
Alright, I'm going to try to explain this as best as possible: I have
I'm going to try to explain this in simple terms, because it's probably shorter
I'm going to try this new cloud technology. So I think the best place
I am going to try to ask this question without supplying too much source
Possible Duplicate: substring and the indexOf method I have this problem that I'm going
I'm going to try to explain this best I can I will provide more
I'm going to try and explain this as simply as I can, it's most
Let me try to clarify my question, I wasn't sure how to word the
I'm going to try to ask my question in the context of a simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.