Checkbox in Datagrid to Filter Output

dev775
dev775 used Ask the Experts™
on
My C# application binds a grid to a datatable, allows the user to edit the data directly in the grid, then a button click event writes the datatable contents to an XML file. The code below describes the very simple code contained in the click event, which works perfectly.  Now I want to provide a checkbox in each row that will allow the user to de-select any records so that they are not to be included in the XML output.  Would appreciate help to find the most efficient method of achieving this.
private void simpleButton2_Click(object sender, EventArgs e)
{
DataTable dt3 = (DataTable)gridControl1.DataSource;
dt3.TableName = "CustomerList";
if (dt3.Rows.Count <= 0)
{
MessageBox.Show("There are no records available");
return;
}
//dt3.WriteXml
dt3.WriteXml(@textBox2.Text + "\\Customer.xml");
{
MessageBox.Show("Data successfully saved to file");
return;
}
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Developer
Commented:
I would add a Boolean column to the datatable.  It should automatically display as a checkbox
you should have a 'Edit' button in the grid clicking which the record is editale. And on clicking 'Cancel' it won't be recorded.  Then it will be easy for you to maintain which records to update and which to skip.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial