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

  • Home
  • SEARCH
  • 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 7913557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:52:20+00:00 2026-06-03T13:52:20+00:00

This is related to a previous question , but it seems different enough to

  • 0

This is related to a previous question, but it seems different enough to post it separately:

I have settings that are stored in string arrays from user input (DomAttributeIds and IntlAttributeIds). I am trying to conditionally build an array of values to execute some code on. Conditions are:

  1. If DomAttributesSettings exist, create an array of the values and pass them to the AddAttributeEdit() method.
  2. If IntlAttributesSettings exist, create an array of those settings and combine them with the settings from condition one distinctly (no duplicates) and pass that array to the rest of the code, and ultimately each array element to the AddAttributeEdit() method.

The code below seems to work except for the “no duplicates” part. I thought using Linq’s Union and/or Distinct methods would do this, but I must be doing something wrong. My code throws the following exception:

Multiple controls with the same ID ‘trAttribute_493’ were found. FindControl requires that controls have unique IDs.

I know that this is because that id exists in both settings. The AddAttributeEdit() method at the end contains code that builds a table and cells with Ids based on the values passed to it. What am I doing wrong to get a distinct union of the two arrays?

Here is the code:

    private void LoadAttributes()
    {
        if (!string.IsNullOrEmpty(DomAttributesSetting))
        {
            string[] attributeIds;
            if (!string.IsNullOrEmpty(IntlAttributesSetting))
            {

                string[] domattributeIds = DomAttributesSetting.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                string[] intlattributeIds = IntlAttributesSetting.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                IEnumerable<string> atrributeIdList = domattributeIds.Union(intlattributeIds).Distinct();
                attributeIds = atrributeIdList.ToArray();
            }
            else
            {
                attributeIds = DomAttributesSetting.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            } 
            foreach (string attributeId in attributeIds)
            {
                int attrId = -1;
                if (int.TryParse(attributeId, out attrId) && attrId != -1)
                {
                    Arena.Core.Attribute attribute = new Arena.Core.Attribute(attrId);
                    PersonAttribute personAttribute = (PersonAttribute)person.Attributes.FindByID(attribute.AttributeId);
                    if (personAttribute == null)
                        personAttribute = new PersonAttribute(person.PersonID, attrId);

                    AddAttributeEdit(attribute, personAttribute, true);
                }

            }


        }

    }...
  • 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-06-03T13:52:21+00:00Added an answer on June 3, 2026 at 1:52 pm

    You probably have padding around the values in the comma delimited lists (e.g “Prop1, Prop2” vs “Prop1,Prop2”) or the casing is different.

    Try trimming each value from the input and using a case-insensitive comparer like this:

    var domattributeIds = DomAttributesSetting
        .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
        .Select(x=>x.Trim());
    
    var intlattributeIds = IntlAttributesSetting
        .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
        .Select(x=>x.Trim());
    
    var attributeIds = domattributeIds
        .Union(intlattributeIds, StringComparer.InvariantCultureIgnoreCase)
        .ToArray();
    

    You shouldn’t even need to call Distinct() at the end.

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

Sidebar

Related Questions

This is related to my previous question , but a different one. I have
This is related to my previous question , but it seems I have another
This is related to my previous question but it is a different problem. I
This question is related to a previous question I asked, but it's a different.
This is somewhat related to my previous question but I've realised that I needed
This is related question to my previous question but different one. After searching a
This is kind of related to my previous question, but not really. I have
Very much related to my previous question , but I found this to be
This question is related to a previous question of mine That's my current code
This question is related to my previous question . The storyline: I have an

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.