public void GetCategoryList()
{
ListComplexOrderCat = new List<ComplexBaseProperty<int, string>>();
if (true)
{
var ListOfCategories = GetContentsRestClient().Get<List<CategoryContentChannel>>("Category");
if (ListOfCategories == null || ListOfCategories.Count == 0)
{
Console.WriteLine("Error, No existen Categorias para insertar un nuevo Articulo");
}
else
{
foreach (CategoryContentChannel category in ListOfCategories)
{
ComplexBaseProperty<int, string> comPropCat = new ComplexBaseProperty<int, string>(
id: category.Id,
value: category.Description.ToString()
);
ListComplexOrderCat.Add(comPropCat);
}
}
}
"ListComplexOrderCat" is a complex List such as:
(Proprety ID / Property Value)
{Id: 1} {Description: Category Random Text 1}
{Id: 2} {Description: Category Random Text 2}
{Id: 3} {Description: Category Random Text 3}
Some Random Namespace
{
[DataContract]
public class ComplexBaseProperty<I, T> : IEquatable<ComplexBaseProperty<I, T>>, IEqualityComparer<ComplexBaseProperty<I, T>>
{
public ComplexBaseProperty();
public ComplexBaseProperty(I id);
public ComplexBaseProperty(I id, T value);
[Column("Id")]
[DataMember(Name = "id")]
public I Id { get; set; }
[Column("Value")]
[DataMember(Name = "value")]
public T Value { get; set; }
public override bool Equals(object obj);
public bool Equals(ComplexBaseProperty<I, T> other);
public bool Equals(ComplexBaseProperty<I, T> x, ComplexBaseProperty<I, T> y);
public override int GetHashCode();
public int GetHashCode(ComplexBaseProperty<I, T> obj);
}
}
This is my Index:
@Html.SelectFormFor(m => m.ListComplexOrderCat.Value, m => m.ListComplexOrderCat.Value, (SelectBaseListAdapter<int, string>)ViewBag.ListDisplayCategory);
So basically my get is returning my list of values... now how can i desplay this? and save the values?
There is a variable on my Model "IdCategory" wich i should use to save de Id selected on the display List.
I Also use another list (for other purpose) working as:
@Html.SelectFormFor(m => m.Article.Order, m => m.Article.Order, (SelectBaseListAdapter<int, string>)ViewBag.ListDisplayOrder);
on that case Article is the Entity for my Model. however for Category list im using values outside this Entity. (I cant use Article).
Come on man! You're showing the community a custom html helper call, @Html.SelectFormFor(), that clearly is designed for your custom generic class. Then ask.
MVC_user
now how can i desplay this? and save the values?
Seriously? You must realize we can only see the code you share.
Member
36 Points
132 Posts
How can i display Values on my List (Razor MVC)
Jan 23, 2020 03:10 PM|MVC_user|LINK
This is my Model:
"ListComplexOrderCat" is a complex List such as:
(Proprety ID / Property Value)
{Id: 1} {Description: Category Random Text 1}
{Id: 2} {Description: Category Random Text 2}
{Id: 3} {Description: Category Random Text 3}
This is my Index:
So basically my get is returning my list of values... now how can i desplay this? and save the values?
There is a variable on my Model "IdCategory" wich i should use to save de Id selected on the display List.
I Also use another list (for other purpose) working as:
on that case Article is the Entity for my Model. however for Category list im using values outside this Entity. (I cant use Article).
All-Star
53131 Points
23682 Posts
Re: How can i display Values on my List (Razor MVC)
Jan 23, 2020 03:54 PM|mgebhard|LINK
Come on man! You're showing the community a custom html helper call, @Html.SelectFormFor(), that clearly is designed for your custom generic class. Then ask.
Seriously? You must realize we can only see the code you share.
Member
36 Points
132 Posts
Re: How can i display Values on my List (Razor MVC)
Jan 24, 2020 05:44 PM|MVC_user|LINK
I fixed this using a checkbox list instead of a list. (have scence if i want to use multiple values).