DataGridView error

D

devx

Hi, i have DataGridView whose sourse i set to a datatable with 5
columns
containing data. i then remove the 3rd column, created a
DataGridViewComboBoxColumn, set it's DataSource, ValueMember and
DisplayMember. the Valumeber is an integer and the displaymember is a
string. I then instert this into the same location as the column that
was
removed. the problem i am getting is when the Grid is loaded, i get
errors
stating "System.FormatException: the value of the
DataGridViewComboBoxCell is
invalid. To replace this default dialog, please handle the DataError
event.".
Why is this error happening?


here is the code that does the replacing and adding of a combo box:


private void addExchangeLookUpCombs( DataGridView dt )
{
dt.Columns.Remove( "exchange_id" );
DataGridViewComboBoxColumn cb = new
DataGridViewComboBoxColumn( );
cb.DataSource =
DbConnection.instance.getDbTable("StockExchange");
cb.ValueMember = "exchange_id";
cb.DisplayMember = "symbol";


cb.FlatStyle = FlatStyle.Flat;
dt.Columns.Insert( 2, cb );


}
 
G

Guest

Hi,
Were you able to figure this out? I'm getting a similar exception and would
like to know how to resolve it. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top