Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Problem adding DataGridViewTextBoxColumn to datatable
Scott McGlothlin
Mar 8 2009 12:35 PM
6.7k
Reply
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.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
how to obtain SQL Server FullText Search service?
Store unicode data