Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
I have a method that will assign the edit mode checkbox value to true. Then when my Update function is called, it will look at those true values on that checkbox and update those rows. This allows user to do multiple updates. It seems to work ok when I make updates manually, but there is a glitch. When I use this
((System.Data.DataTable)dgvClientData.DataSource).Select("Mode=true");


it doesn't find any rows even though the item array column value ["Mode"] is true. Any ideas why?

C#
<pre>private void toolStripComboBox1_DropDownClosed(object sender, EventArgs e)
{
     IEnumerable<System.Data.DataRow> UpdatedRecords;
     string selectedResult = (toolStripComboBox2.Items[toolStripComboBox2.SelectedIndex].ToString());
     if (selectedResult == "Both")
         selectedResult = string.Join(", ", _arr.ToArray());
     context.Close();
     
     if ((this.dgvClientData.SelectedRows.Count > 0) && (!dgvClientData.CurrentRow.IsNewRow))
     {
        DialogResult dar = MessageBox.Show("Are you sure you want to assign ClientID: " + selectedResult + " to selected Client IDs? ", "Confirm update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        
        if (dar == DialogResult.Yes)
        {
            foreach (DataGridViewRow dr in this.dgvClientData.SelectedRows)
            {
                 (dr.Cells["Mode"] as DataGridViewCheckBoxCell).Value = CheckState.Checked;
                 dr.DefaultCellStyle.BackColor = Color.DarkGray;
            }
        UpdatedRecords = ((System.Data.DataTable)dgvClientData.DataSource).Select("Mode=true");
                 UpdateDestination();
        }
   }
}
Posted
Updated 14-Aug-14 14:17pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900