(Collection)

S

shapper

Hello,

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
 
S

shapper

Hello,

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

Hi,

I was able to solve this. My C# was ok. The problem was really with
MVC.

Thank You,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ToString and FromString 10
List 2
Linq. Please, need help. 1
Condition 2
Filter 1
Linq Query. Please, help. Going crazy ... 1
List to CSV 3
Local Sequence cannot be used ... except the Contains() operator 4

Top