Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > bind cusom object to datagrid not working
 

bind cusom object to datagrid not working

hello
i have a object being set in my form as a property.

private Order order;

public Order Order

{

set {

order = value;
}

i want to bind the datagrid on my form datagrid1 to this order object.
how do i do it.


i event tried the following code but cannot see the data in the datagrid. however thetracer has the data. so what am i doing wrong.
appreciate help

dataGridOrderDetails.DataSource = order;

dataGridOrderDetails.Refresh();



TTrace.Warning.Enabled = true;

TTrace.Warning.Send("Hello world true from tradecommander");

TTrace.Warning.Send("order state" + order.OrderState);

TTrace.Debug.SendValue("Object instance", order);

TTrace.Warning.Send("Hello", order.Name);

dilibu  Wednesday, December 24, 2008 6:56 PM
I see you are trying to bind a Order class to a datagrid. Does your Order class meeting the follow requirements to be bound to a datagrid?

To display a table in the System.Windows.Forms..::.DataGrid at run time, use the SetDataBinding method to set the DataSource and DataMember properties to a valid data source. The following data sources are valid:

For more information about the DataSet class, see DataSets, DataTables, and DataViews (ADO.NET).


http://msdn.microsoft.com/en-us/library/system.windows.forms.datagrid.aspx



Orlando Code Camp March 28, 2009 http://www.orlandocodecamp.com
Ken Tucker  Thursday, December 25, 2008 1:25 PM
I see you are trying to bind a Order class to a datagrid. Does your Order class meeting the follow requirements to be bound to a datagrid?

To display a table in the System.Windows.Forms..::.DataGrid at run time, use the SetDataBinding method to set the DataSource and DataMember properties to a valid data source. The following data sources are valid:

For more information about the DataSet class, see DataSets, DataTables, and DataViews (ADO.NET).


http://msdn.microsoft.com/en-us/library/system.windows.forms.datagrid.aspx



Orlando Code Camp March 28, 2009 http://www.orlandocodecamp.com
Ken Tucker  Thursday, December 25, 2008 1:25 PM

You can use google to search for other answers

Custom Search

More Threads

• How to use one bindingNavigator to navigate through two tables?
• NullReferenceException
• Unhandled FormatException (?)
• Refresh DataSet from SQL Server 2005
• Problem with focus on tab control
• Binding multiple sources to 1 datagridview
• Maintaining the selected row after sorting a DataGridView
• RowFilter Problem with DataView
• Creating A Dot Net Windows Summary to Detail Application
• DataGridView formatting before cell editing