S
shapper
Hello,
Tags = String.IsNullOrEmpty(binding.ValueProvider
["Tags"].AttemptedValue) ? new List<Tag>()
: ((String)binding.ValueProvider["Tags"].ConvertTo(typeof
(String)))
.Split(new char[] { ',' },
StringSplitOptions.RemoveEmptyEntries).Select(t => new Tag() { Name =
t.Trim() }).ToList()
To display the list on the Text Box I am using:
<%=Html.TextBox("Tags", Model.Article.Tags != null ? String.Join(", ",
Model.Article.Tags.Select(t => t.Name).ToArray()) : String.Empty, new
{ @class = "Text Long" })%>
I think the problem is in this second part because I always get
"(Collection)" instead of a CSV String format.
Model.Article.Tags != null ? String.Join(", ",
Model.Article.Tags.Select(t => t.Name).ToArray()) : String.Empty
Can someone see what am I doing wrong?
I can't find it.
Thanks,
Miguel
Get the text from the text box (Movie, New York, 2009)
Split the string
Create a list of Tags where each Tag.Name is a word of the list:
Tags = String.IsNullOrEmpty(binding.ValueProvider
["Tags"].AttemptedValue) ? new List<Tag>()
: ((String)binding.ValueProvider["Tags"].ConvertTo(typeof
(String)))
.Split(new char[] { ',' },
StringSplitOptions.RemoveEmptyEntries).Select(t => new Tag() { Name =
t.Trim() }).ToList()
To display the list on the Text Box I am using:
<%=Html.TextBox("Tags", Model.Article.Tags != null ? String.Join(", ",
Model.Article.Tags.Select(t => t.Name).ToArray()) : String.Empty, new
{ @class = "Text Long" })%>
I think the problem is in this second part because I always get
"(Collection)" instead of a CSV String format.
Model.Article.Tags != null ? String.Join(", ",
Model.Article.Tags.Select(t => t.Name).ToArray()) : String.Empty
Can someone see what am I doing wrong?
I can't find it.
Thanks,
Miguel