Posted 31 March 2023, 12:37 am EST - Updated 31 March 2023, 12:39 am EST
Fearly new to this. I am trying to create a combobox column specifying both key and displayvalue.
For now I only use an empty List<KeyValuePair<string,string>> named test as datasource for the column.
It will not compile and gives the following error
**Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from ‘System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<string, string>>’ to ‘System.Action<C1.Web.Mvc.Fluent.CollectionViewServiceBuilder>’ SWPP C:\Users\reidar.BAS\source\repos\ShipWeightPlussMVC\SWPP\Views\ItemFl\Index.cshtml 59 Active
**
It fails here:
.DataMap(dm => dm.DisplayMemberPath(“Key”).SelectedValuePath(“Value”).Bind(test))
@{
string[] statuses = ViewBag.Statuses;
List<KeyValuePair<string, string>> test = new List<KeyValuePair<string, string>>();
}
@(Html.C1().FlexGrid<SWPP.Models.ITEM_ViewItem>()
.Bind( bl => bl.InitialItemsCount(100) .Bind(Url.Action("GridReadData")) .Update(Url.Action("GridUpdateItem")) .Delete(Url.Action("GridDeleteItem")) .Create(Url.Action("GridCreateItem")) ) .Id("theGrid") .AutoGenerateColumns(false) .IsReadOnly(false) .Height("800px") .Filterable(f => f.DefaultFilterType(FilterType.Both)) .AutoSearch(true) .CaseSensitiveSearch(true) .CssClass("grid") .AutoRowHeights(false) .AllowDelete(true) .AllowAddNew(true) .NewRowAtTop(false) .SelectionMode(SelectionMode.MultiRange) .Columns(b => { b.Add(cb => cb.Binding("ProjectID").Visible(false)); b.Add(cb => cb.Binding("UniqueNo").Visible(false)); foreach (var h in Model.Headers) { if (h.InputSpec.Type == ShipWeightPlussMVC.Models.InputSpec.InputTypes.Edit) { b.Add(cb => cb .Binding(h.FieldName) .Header(h.Caption) .DataType(h.DataType) .IsReadOnly(h.ReadOnly) ); } else { b.Add(cb => cb .Binding(h.FieldName) .DataMapEditor(DataMapEditor.DropDownList) .DataMap(dm => dm.DisplayMemberPath("Key").SelectedValuePath("Value").Bind(test)) .Header(h.Caption) .Editor($"{h.FieldName}Editor") .DataType(h.DataType) .IsReadOnly(h.ReadOnly) ); } } })
)