Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1042409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:30:17+00:00 2026-05-16T15:30:17+00:00

i have this model on mvc: public class User { public string Name {

  • 0

i have this model on mvc:

public class User
{
    public string Name
    {
      get;
      set;
    }
    public IList<string>RelatedTags
    {
      get;
      set;
    }
}

And the following typed view (user) to edit an add a user (AddEdit.aspx view):

<div>
   <%: Html.LabelFor(e => e.Name)%>
   <%: Html.TextBoxFor(e => e.Name)%>
   <%: Html.ValidationMessageFor(e => e.Name)%>
</div>
<div>
   <%: Html.LabelFor(e => e.RelatedTags)%>
   <%: Html.TextBoxFor(e => e.RelatedTags)%>
   <%: Html.ValidationMessageFor(e => e.RelatedTags)%>
</div>

For other hand i have a “RelatedTags” field. I needed (on action controller side) a List of tags related with the user that im adding. For this reason i created a Custom model binder (to take the string of the textbox and pass it as List):

public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
   List<string> listoftags = bindingContext.ValueProvider.GetValue("RelatedTags").AttemptedValue.Split(',').ToList<string>();
     return listoftags;
}

Actually i can use the AddEdit.aspx to add a new user (on controller side im getting a List of related tags, but when i edit a user i dont know where i can convert this List to comma string, and either i dont know should change these lines on the view:

<div>
       <%: Html.LabelFor(e => e.RelatedTags)%>
       <%: Html.TextBoxFor(e => e.RelatedTags)%>
       <%: Html.ValidationMessageFor(e => e.RelatedTags)%>
</div>

By the moment, just in case, i created an extension method for the IList:

public static class Extensions
    {
        public static string ToCommaString<T>(this IList<T> input)
        {
            StringBuilder sb = new StringBuilder();
            foreach (T value in input)
            {
                sb.Append(value);
                sb.Append(",");
            }
            return sb.ToString();
        }
    }

Could you give me any help for when im editing a user see in the input field a string separated with commas with all the elements of the list?

Thanks a lot in advance.

Best Regards.

Jose.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:30:17+00:00Added an answer on May 16, 2026 at 3:30 pm

    Maybe you could use this model?

    public class UserModel
    {
        public string Name { get; set; }
        protected IList<string> RelatedTagsList { get; set; } 
        public string RelatedTags
        {
            get
            {
                return string.Join(",", RelatedTagsList.ToArray());
            }
    
            set
            {
                RelatedTagsList = value.Split(',').ToList();
            }
        }
    }
    

    No binders and extension methods required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model class like following public class ProductModel { string ProductName {
I'm building an MVC 3 website. I have a model looking like this: public
I'm following this MVC model: http://java.sun.com/developer/technicalArticles/javase/mvc/ In my model I have an ArrayList shapes
I have the following class... public class Product { public int Id { get;
I have this model in django: class JournalsGeneral(models.Model): jid = models.AutoField(primary_key=True) code = models.CharField(Code,
Assume I have this model : class Task(models.Model): title = models.CharField() Now I would
I'm using FluentNHibernate but NHibernate XML will do. Say I have this model public
I have this Project model: class Project < ActiveRecord::Base validates :status, :inclusion => {
I am building a ASP.NET Mvc app. I have a Data model say User
My simplified domain model looks something like this: public abstract class Entity<IdK> { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.