我有以下的下拉菜单:
public class object {
public other_object apple {get; set;}
...
public string stuff {get; set;}
...
}
public class other_object {
public string id {get; set;}
public string name {get; set;}
}
<select class="custom-select" @bind="@object.apple">
<option value="@object.apple">@object.apple.name</option>
...
</select>
我希望将select绑定到一个对象,但只想显示该对象的一些属性。 这会导致以下错误:
System.InvalidOperationException:类型“other_object”没有关联的TypeConverter支持从字符串进行转换。请将“TypeConverterAttribute”应用于该类型以注册转换器。
这个可行吗?我不太确定类型转换器是如何工作的。