0

I implemented the following method to get array of departments to bind to dropdownlist

public object[] GetDepartmentOptions()
{
   var departments = from p in context.per_Departments
                     where p.active == true
                     select new { DisplayText = p.departmentNameEn, 
                                  Value = p.departmentId };
   return departments.ToArray();
}

I would like to insert object in this array before bind it

object =new { DisplayText = "Choose", Value = 0 };

1 Answer 1

2

For some reason it works only if your first sequence is the "choose" sequence:

    var first = new[] { new { DisplayText = "Choose", Value = 0 } };
    return first.Concat(departments).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.