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 1047827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:21:43+00:00 2026-05-16T16:21:43+00:00

I am trying hard to update a business object inside a List<>. I am

  • 0

I am trying hard to update a business object inside a List<>.

I am using a checkbox list

  1. When a checkbox list item is clicked
  2. I check if it exists, if yes I mark it as Dirty (means the user unchecks an item)
  3. If not, I add a new item to the list (means the user clicks a new item)
    and store it in view state

    How do I update the Generic List with the Dirty Object ?
    On form update, do I foreach and make separate lists of dirty and new objects to send to DB layer or would you recommend any other way ?

Here is my code, sorry about the bad logic I am just a starter =(

protected void cblExclusions_SelectedIndexChanged(object sender, EventArgs e)
{
   if (cblExclusions.SelectedIndex != -1)
    {
        ftExclusions myExclusion=new ftExclusions();  // Business object
        ftExclusionsList myExclusionList=new ftExclusionsList();   // Business Obj. List
        int excId = Convert.ToInt32(cblExclusions.SelectedValue.ToString()); // value of checkbox list item which is clicked
        ftExclusionsList tempList = (ftExclusionsList)ViewState["ftExclusionList"];

        ftExclusions isExist =tempList.Find(delegate(ftExclusions tmpExclusion)
            {
                return (tmpExclusion.excluId == excId);
            });

        if (isExist != null)
        {
            isExist.isDirtyExclusion(); // Mark as dirty
            tempList.  // stuck here I don't grasp how to save this back to the list 
        }
        else
        {
            myExclusion = new ftExclusions();
            myExclusion.excluId = excId;
            myExclusion.fTrtID = Convert.ToInt32(lblTreatyNo.Text);
            myExclusion.ftExcluId = -1;     //new record
            myExclusion.isNewExclusion();   // Mark as new
            tempList.Add(myExclusion);
        }
        ViewState["ftExclusionList"] = tempList;                

    }
}
  • 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-16T16:21:44+00:00Added an answer on May 16, 2026 at 4:21 pm

    You do no need to save it back to the list. Assuming ftExclusions is class and not struct, it is always passed by reference. Meaning that both tempList and isExist contain reference to the same object. And any changes on the object will be visible from both places.

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

Sidebar

Related Questions

I'm having a hard time trying to track down an error. I'm using a
I'm trying to update a Google Map (API V3) with markers using my friends
I am trying to update a #temp table from a linked server using a
I have been trying very hard to achieve rounded corners with IE6+jquery ui tabs.
I've been trying excessively hard to implement a good open id solution into asp.net
I've had a hard time trying to find good examples of how to manage
I've been having a hard time trying to understand PyPy's translation. It looks like
I'm having a hard time trying to get my team comfortable with interface based
I'm having a hard time trying to make a Java program with just a
I'm having hard time trying to figure out how to auto-save user data in

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.