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.
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.
Scott McGlothlinPosted Mar 8, 2009, 11:51 PM
DataGridViewTextBoxColumn textBoxMarg = new DataGridViewTextBoxColumn();
textBoxMarg.Name = "textBoxMarg";
textBoxMarg.HeaderText = "NEW MARGIN";
textBoxMarg.Width = 62;
dataGridView1.Columns.Add(textBoxMarg);
DataColumn marg = new DataColumn("marg");
dataGridView1.Columns["textBoxMarg"].DataPropertyName = "marg";
ds1.Tables["addcol"].Columns.Add(marg);
Instead of creating the new datatable "dt" I just named it when I filled the data adapter:
dbDA.Fill(ds1, "addcol");
That along with the proper order and syntax did it.
Thanks.