I have tried any number of ways to include a DataGridViewTextBoxColumn in the datatable, to no avail. The column adds just fine to the DataGridView, just not the underlying datatable. This is what I have now:
DataColumn marg = new DataColumn("marg", typeof(decimal));
dt.Columns.Add("marg");
DataGridViewTextBoxColumn textBoxMarg = new DataGridViewTextBoxColumn();
textBoxMarg.DataPropertyName = "marg";
textBoxMarg.Name = "textBoxMarg";
textBoxMarg.HeaderText = "NEW MARGIN";
textBoxMarg.Width = 62;
dataGridView1.Columns.Add(textBoxMarg);
I am using a "foreach" loop to search for the added column and it's not there. Nor can I reference it when trying to insert it's value to the database.
foreach (DataTable table in ds1.Tables)
{
foreach (DataColumn column in table.Columns)
{
MessageBox.Show("column", Convert.ToString(column));
}
}
Ultimately the user will enter desired margin and I need to insert that value into a SQL table to use with a stored procedure.
Any direction here would be much appreciated, as I'm starting to wear a flat spot on my forehead over this one.