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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:28:44+00:00 2026-05-30T17:28:44+00:00

I have 2 datagrids. Both with checkboxes. I have a nested foreach loop that

  • 0

I have 2 datagrids. Both with checkboxes. I have a nested foreach loop that gets the DataKeys values of both checked persons from both datagrids. When I run the debugger the first datakey gets assigned to the correct variable oIdividualID. That is working fine. The second foreach loop gets the datakey from the next datagrid. That works fine too. However, it is not assigning it to the variable oNewParentID. and At the bottom of my code, in debugging, the method I am calling holds the value of oIndividualID correctly, But oNewParentID Holds NO value? Is there something wrong with my nested foreach loop? I don’t understand. Here’s my code:

protected void imgbtnReassgin_Click(object sender, ImageClickEventArgs e)
{
    foreach (GridViewRow row in gvAdminCustomer.Rows)
    {
        CheckBox cb = (CheckBox)row.FindControl("chkitemSelectorCustomers");
        if (cb != null && cb.Checked)
        {
            int oIndividualID  = Convert.ToInt32((gvAdminCustomer.DataKeys[row.RowIndex].Value));

            foreach (GridViewRow r in gvReassignCustomers.Rows)
            {
                CheckBox chkBox = (CheckBox)row.FindControl("chkitemSelectorAllManagersandSalesman");
                if (chkBox != null && chkBox.Checked)
                {
                    int oNewParentID = Convert.ToInt32((gvReassignCustomers.DataKeys[r.RowIndex].Value));
                    Individual ind = new Individual();
                    ind.ReassignIndividual(oIndividualID, oNewParentID);
                }
            }
            gvReassignCustomers.DataBind();
            gvAdminCustomer.DataBind();
        }
    }
}
  • 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-30T17:28:45+00:00Added an answer on May 30, 2026 at 5:28 pm

    hard to understand the purpose of the code – for every checked tickbox in Admin grid you’re running reassign on every checked Reassign grid. Is it really the intent?

    And then you’re running DataBind() for every line on in admin grid.

    So.

    Comment out DataBind() – you don’t need them there, it’s just tells the system to rebind the data to the grids which can potentially clear the user ticked tickboxes.

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

Sidebar

Related Questions

The situation is simple. I have a datagrid that gets its data from a
I have two silverlight (2 or 3) datagrids (from the July 2009 Silverlight toolkit)
I have a WPF application with two DataGrids that share the same ItemsSource. When
I have an AIR application with two DataGrids that I would like to export
Let's say you have a form with a component that displays data from a
I have a WinDataGrid class that extends from an Infragistics UltraGrid . I have
I have defined an XMLList which gets its data from the following XML file:
I have such task - to create control that union two controls (DataGrid from
Lets say I have multiple DataGrids throughout my winform app and I want to
I have a DataGrid, with an ItemTemplate that has an image and label. 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.