Problem with Inserting an item to a list

Discussion in 'C#' started by atuvy, Aug 31, 2010.

  1. atuvy

    atuvy New Member

    Joined:
    Aug 31, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I am not sure if this is the appropriate forum for my question but I think it is more of a general c# problem than LINQ

    I am running a LINQ query which populates a list used by a DropDownList, I need to insert an "Unassigned" value to the list. The function below queries the values correctly from the db but does not insert the "Unaasinged" value to the list. Please help.


    Code:
    public List GetTestList()
            {
                KeyValuePair item = new KeyValuePair(0, "Unassigned");
    
                using (DataClassesDataContext db = new DataClassesDataContext())
                {
                    var Query = from records in db.TEST_SUITEs
                        orderby records.TEST_SUITE_ID
                        select new KeyValuePair
                        (
                            records.TEST_SUITE_ID, string.Format(records.TEST_SUITE_ID + " " + records.SUITE_TYPE + " " + records.SUITE_NAME)
                        );
                    //Query.ToList().Insert(0, item);
                    Query.ToList().Insert(0,item);
                    return Query.ToList();
                }
            }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice