On May 8, 3:57*pm, shapper <mdmo...@gmail.com> wrote:
> Hello,
>
> On an ASP.NET MVC project I am binding a text box.
>
> In this case binding can be described as follows:
>
> > 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
|