finance_teacher
asked on
C# -- BindingSource -- "RemoveCurrent" ?
The below "gML_ROITEMBindingSource.R emoveCurre nt();"
only removes the current ROW.
How can I remove ALL rows after the user SUBMITS
so the gML_ROITEMDataGridView is BLANK again so
the user can submit more records ?
-------------------------- ---------- ---------- ---------- ----------
private void btn_Submit_Click(object sender, EventArgs e)
{
if (cboVendor.Text == "")
{
MessageBox.Show("Enter a vendorNumber");
return;
}
else
{
this.Validate();
decimal iGML_ROMSTR_ID = 0;
try
{
DataSet1TableAdapters.GML_ SEQ_ROMSTR TableAdapt er adpSeq = new OrderEntry.DataSet1TableAd apters.GML _SEQ_ROMST RTableAdap ter();
DataSet1.GML_SEQ_ROMSTRDat aTable tb = adpSeq.GetData();
if (tb != null && tb.Rows.Count > 0)
{
if (tb.Rows[0][0] != DBNull.Value)
{
iGML_ROMSTR_ID = Convert.ToDecimal(tb.Rows[ 0][0]);
}
}
decimal TEMP_locNum = 0;
decimal TEMP_palletsReq = 0;
decimal TEMP_imId = 0;
string TEMP_Priority = String.Empty;
decimal TEMP_vendId = 0;
for (int i = 0; i < gML_ROITEMDataGridView.Row s.Count - 1; i++)
{
// change below [] when column NAME changes
TEMP_locNum = (decimal)this.gML_ROITEMDa taGridView ["LOC_NUM" , i].Value;
TEMP_imId = (decimal)this.gML_ROITEMDa taGridView ["IM_ID", i].Value;
TEMP_palletsReq = (decimal)this.gML_ROITEMDa taGridView ["PALLETSR EQ", i].Value;
TEMP_Priority = this.gML_ROITEMDataGridVie w["PRIORIT Y", i].Value.ToString();
TEMP_vendId = (decimal)this.gML_ROITEMDa taGridView ["VENDNO", i].Value;
//below inserts locnum-itemID-pallets-pri- date-user- RO#-vend#
this.gML_ROITEMTableAdapte r.InsertQu ery(TEMP_l ocNum, 177982, TEMP_palletsReq, TEMP_Priority, DateTime.Today, 42, iGML_ROMSTR_ID, TEMP_vendId);
}
gML_ROITEMBindingSource.Re moveCurren t();
}
catch (Exception ex)
{
MessageBox.Show("Assign Error-> " + ex.Message);
}
}
}
only removes the current ROW.
How can I remove ALL rows after the user SUBMITS
so the gML_ROITEMDataGridView is BLANK again so
the user can submit more records ?
--------------------------
private void btn_Submit_Click(object sender, EventArgs e)
{
if (cboVendor.Text == "")
{
MessageBox.Show("Enter a vendorNumber");
return;
}
else
{
this.Validate();
decimal iGML_ROMSTR_ID = 0;
try
{
DataSet1TableAdapters.GML_
DataSet1.GML_SEQ_ROMSTRDat
if (tb != null && tb.Rows.Count > 0)
{
if (tb.Rows[0][0] != DBNull.Value)
{
iGML_ROMSTR_ID = Convert.ToDecimal(tb.Rows[
}
}
decimal TEMP_locNum = 0;
decimal TEMP_palletsReq = 0;
decimal TEMP_imId = 0;
string TEMP_Priority = String.Empty;
decimal TEMP_vendId = 0;
for (int i = 0; i < gML_ROITEMDataGridView.Row
{
// change below [] when column NAME changes
TEMP_locNum = (decimal)this.gML_ROITEMDa
TEMP_imId = (decimal)this.gML_ROITEMDa
TEMP_palletsReq = (decimal)this.gML_ROITEMDa
TEMP_Priority = this.gML_ROITEMDataGridVie
TEMP_vendId = (decimal)this.gML_ROITEMDa
//below inserts locnum-itemID-pallets-pri-
this.gML_ROITEMTableAdapte
}
gML_ROITEMBindingSource.Re
}
catch (Exception ex)
{
MessageBox.Show("Assign Error-> " + ex.Message);
}
}
}
what type of object is: gML_ROITEMBindingSource
ASKER
It is the attached "Toolbox" CONTROL.
0001.jpg
0001.jpg
replace
gML_ROITEMBindingSource.Re moveCurren t();
with:
gML_ROITEMBindingSource.Cl ear();
gML_ROITEMBindingSource.Re
with:
gML_ROITEMBindingSource.Cl
or:
private void btn_Submit_Click(object sender, EventArgs e)
{
if (cboVendor.Text == "")
{
MessageBox.Show("Enter a vendorNumber");
return;
}
else
{
this.Validate();
decimal iGML_ROMSTR_ID = 0;
try
{
DataSet1TableAdapters.GML_SEQ_ROMSTRTableAdapter adpSeq = new OrderEntry.DataSet1TableAdapters.GML_SEQ_ROMSTRTableAdapter();
DataSet1.GML_SEQ_ROMSTRDataTable tb = adpSeq.GetData();
if (tb != null && tb.Rows.Count > 0)
{
if (tb.Rows[0][0] != DBNull.Value)
{
iGML_ROMSTR_ID = Convert.ToDecimal(tb.Rows[0][0]);
}
}
decimal TEMP_locNum = 0;
decimal TEMP_palletsReq = 0;
decimal TEMP_imId = 0;
string TEMP_Priority = String.Empty;
decimal TEMP_vendId = 0;
for (int i = 0; i < gML_ROITEMDataGridView.Rows.Count - 1; i++)
{
// change below [] when column NAME changes
TEMP_locNum = (decimal)this.gML_ROITEMDataGridView["LOC_NUM", i].Value;
TEMP_imId = (decimal)this.gML_ROITEMDataGridView["IM_ID", i].Value;
TEMP_palletsReq = (decimal)this.gML_ROITEMDataGridView["PALLETSREQ", i].Value;
TEMP_Priority = this.gML_ROITEMDataGridView["PRIORITY", i].Value.ToString();
TEMP_vendId = (decimal)this.gML_ROITEMDataGridView["VENDNO", i].Value;
//below inserts locnum-itemID-pallets-pri-date-user-RO#-vend#
this.gML_ROITEMTableAdapter.InsertQuery(TEMP_locNum, 177982, TEMP_palletsReq, TEMP_Priority, DateTime.Today, 42, iGML_ROMSTR_ID, TEMP_vendId);
}
//gML_ROITEMBindingSource.RemoveAt(i);
foreach (BindingSource source in gML_ROITEMBindingSource.List)
gML_ROITEMBindingSource.Remove(source);
}
catch (Exception ex)
{
MessageBox.Show("Assign Error-> " + ex.Message);
}
}
}
ASKER
are you trying to remove the rows from the grid ?
ASKER
Yes, remove ALL rows after the user SUBMITS
so the gML_ROITEMDataGridView is BLANK again so
the user can submit more records.
so the gML_ROITEMDataGridView is BLANK again so
the user can submit more records.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Still fails, but below is a SOLUTION I found.
SOLUTION
myDataSet.<table name>.clear()
Example
dataSet1.GML_ROITEM.Clear( );
SOLUTION
myDataSet.<table name>.clear()
Example
dataSet1.GML_ROITEM.Clear(