i have a datagrid which has checkboxes in it. and a save button
the behavior of my form is that it saves all the changes in the datagrid.
as of now, my form only accepts one changes from the datagrid. eventhough i checked all the checkboxes in the datagrid, it wont save the changes... below is my code:
private void frmApprovingCustomerPO_Load(object sender, EventArgs e)
{
BindData();
}
private void BindData()
{
CustomerPOApprovalBL custBL = new CustomerPOApprovalBL();
ds = custBL.PopulateGrid(chkboxApprovedPO.Checked);
if (this.ds != null)
{
this.dataGridView1.AutoGenerateColumns = false;
dataGridView1.DataSource = ds.Tables[0];
this.dataGridView1.Columns[0].DataPropertyName = "Purchase No";
this.dataGridView1.Columns[1].DataPropertyName = "CustomerCode";
this.dataGridView1.Columns[2].DataPropertyName = "Customer Name";
this.dataGridView1.Columns[3].DataPropertyName = "PO Date";
this.dataGridView1.Columns[4].DataPropertyName = "Status";
this.dataGridView1.Columns[5].DataPropertyName = "Date";
this.dataGridView1.Columns[6].DataPropertyName = "Approved";
ds.Tables[0].RowChanged += new DataRowChangeEventHandler(frmApprovingCustomerPO_RowChanged);
}
this.dataGridView1.Refresh();
}
private void btnQuery_Click(object sender, EventArgs e)
{
BindData();
}
private void btnSave_Click(object sender, EventArgs e)
{
int retVal;
CustomerPOApprovalBL custBL = new CustomerPOApprovalBL();
if (ds != null)
{
foreach (DataRow row in this.ds.Tables[0].Rows)
{
if (row.RowState == DataRowState.Modified)
{
retVal = custBL.updateStatus(ds.Tables[0].GetChanges());
}
}
}
BindData();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void frmApprovingCustomerPO_RowChanged(object sender, DataRowChangeEventArgs e)
{
string s = e.Row.RowState.ToString();
if (bool.Parse(e.Row[7].ToString()))
{
if (Convert.ToChar(e.Row[5]) == 'A') return;
e.Row[5] = 'A';
}
else
{
if (Convert.ToChar(e.Row[5]) == 'U') return;
e.Row[5] = 'U';
}
}
thanks.