I have a comboboxfor like the following:
@(Html.Infragistics().ComboFor(item => item.DocumentViewModel.Purpose) .AutoComplete(true) .FilteringType(ComboFilteringType.Local) .FilteringCondition(ComboFilteringCondition.StartsWith) .Width("100%") .Height("34px") .ValueKey("Purpose") .TextKey("Purpose") .DataSourceUrl(Url.Action("purpose-combo-data")) .DataBind() .Render() )
The key and value happens to be same, but I think the problem is that the model has a subclass, and the value passed from the model is not selecting in the combobox. The dropdown list is fine.
This combobox was working well in version 14.2, but I noticed this after upgrading to 15.2
Hello,
Could you provide me with more details of how your Model is constructed. Could you give me an example of a data item that the combo would be bound to? From what I'm seeing here it looks like you expose a Purpose object in your model when then has a string based Purpose property. Having this information will aid me in reproducing the behavior on my end.
Here are my models:
public class EditDocumentViewModel { [Display(Name = "Is New")] public bool IsNewRecord { get; set; } [Display(Name = "File Required")] public bool FileRequired { get; set; } public DocumentViewModel DocumentViewModel { get; set; } }
and
public class DocumentViewModel { public string DocumentID { get; set; } [Display(Name = "File Name")] public string FileName { get; set; } [Display(Name = "Number")] public string DocumentNumber { get; set; } [Display(Name = "Description")] public string DocumentDescription { get; set; } [Display(Name = "Purpose")] public string Purpose { get; set; } [Display(Name = "Folder")] public string Folder { get; set; } [Display(Name = "Type")] public string FileType { get; set; } [Display(Name = "Document")] [RequiredIf("FileRequired", RequiredIfAttribute.CompareType.EqualTo, "True", "A file is required.")] public HttpPostedFileBase Document { get; set; } [Display(Name = "Created On")] public string CreatedOn { get; set; } [Display(Name = "Modified On")] public string ModifiedOn { get; set; } }
The string Purpose serves as the key and value. I am using the EditDocumentViewModel in my page with the DocumentViewModel defined as part of that object. I know that ASP doesn't translate dot notation directly when it forms the name in an input tag, instead it replaces the dot with an underscore, as in DocumentViewModel.Pupose to DocumentViewMode_Purpose if that helps.