locked
Foreign Key Autocomplete RRS feed

  • Question

  • User-552465037 posted

    I'd like my foreign key field templates to be autocomplete on edit.  The users have asked for the ability to type their selections because the dropdowns take too long but I think they might come in handy sometimes so I don't want to completely eliminate the dropdown.  I found Steve's sample for an advanced field template (http://csharpbits.notaclue.net/2008/07/dynamic-data-and-field-templates_28.html) but he makes it clear that it doesn't work with foreign keys.  So how can I use autocomplete on my foreign key columns or is there a different method that will work better to give my users what they want?  I am using DD 4.

    Thanks!

    Lee Ann

    Thursday, March 24, 2011 1:48 PM

Answers

  • User-330204900 posted

    Hi Lee, I deliberaly change it to work with Text field, if you email me directly I can send you a .Net 4 Autocomplete field template.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 24, 2011 3:37 PM

All replies

  • User-330204900 posted

    Hi Lee, I deliberaly change it to work with Text field, if you email me directly I can send you a .Net 4 Autocomplete field template.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 24, 2011 3:37 PM
  • User232504566 posted

    Im struggling turning this field template into something the EF can work with.

     

    return queryable.Cast<object>().Select(row => CreateAutoCompleteItem(table, row)).ToArray();

    That line in the AutoCompleteFilter doesnt work. The error i get is

    LINQ to Entities only supports casting Entity Data Model primitive types.

     

    Any Ideas?

    Tuesday, March 29, 2011 10:28 AM
  • User232504566 posted

    Replaced the Line with

                var values = new List<String>();
                foreach (var row in queryable)
                {
                    values.Add( CreateAutoCompleteItem(table, row));
                }
    
                return values.ToArray(); 
    from your dynamic data 5 cool filters for EF and it worked out great! thanks

    Tuesday, March 29, 2011 11:09 AM