PC Review


Reply
Thread Tools Rate Thread

(Collection)

 
 
shapper
Guest
Posts: n/a
 
      8th May 2009
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
 
Reply With Quote
 
 
 
 
shapper
Guest
Posts: n/a
 
      8th May 2009
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
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Řyvind Isaksen Microsoft ASP .NET 1 18th May 2007 10:24 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Řyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
Can't get collection to save when using collection of custom class as property of control in VS 2005 J.Edwards Microsoft Dot NET Compact Framework 0 10th Jan 2006 04:44 AM
key/value collection that allows key string to be updated and retains collection item entry order dx Microsoft Dot NET Framework 2 25th Sep 2004 05:51 PM
Item Collection Editor doesn't preserve collection Andrés Giraldo Microsoft ASP .NET 2 25th Mar 2004 08:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:51 PM.