0

I have an accordion that binds data for each item from an array. I want that for every time that I bound the data I will loop through all of the array and aggregate all of the items with the same id and create a long string with a name from a cell. In the code the name oneJob.order_id does not exist and I don't know why.

protected string GetAllProffesions(int orderID)
{
    IEnumerable<string> allProf;
    orderID = 544;
    Job[] curItems = null;
    curItems = JobManager.GetJobs(RangeID, GetParam());
    allProf = from oneJob in curItems
              where oneJob.order_id == orderID
              select oneJob.profession_name;

    return Convert.ToString(allProf);
}
4
  • 2
    Does your Job class has order_id field ? You can use String.Join to join a string Commented Jun 11, 2012 at 8:43
  • Just to be sure: Has your "Job"-class a property or field named "order_id" that is accessible from this method? Commented Jun 11, 2012 at 8:44
  • Where does the Job come from? Is it a manually created class or a product of an ORM (LINQ to SQL or Entity Framework or NHibernate etc.)? Commented Jun 11, 2012 at 8:45
  • Yes Job has order_id and it was created earlier,once i press "." it gives all the proprieties that i have in Job. Job is manually created in the program. Commented Jun 11, 2012 at 13:29

1 Answer 1

1

This is because your job class doesn't have a property called order_id. Check your spelling.

Also, you probably don't want to do Convert.ToString(allProf), as I expect this will give you the type name instead of all the professions concatenated. Try this instead:

string.Join(", ", allProf.ToArray());

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.