Cant find the databind for data grid

  • Thread starter Thread starter Roger Twomey
  • Start date Start date
R

Roger Twomey

Okay, I am really confused. I have this code:

Conn.Open()
DataGrid1.DataSource = command.ExecuteReader(CommandBehavior.CloseConnection)

I have opened the connection, I set the data source, now I want to bind. I SHOULD be able to say 'DataGrid1.DataBind()' but it tells me that DataBind is not a member of windows.forms.datagrid.

What gives??

I use that syntax all the time in asp.net.
 
Dear Roger,
You are right that this syntax works in ASP.NET but
ASP.NET DataGrid is derived from System.Web.UI.WebControls.WebControl
and The grid you are using in a Winform is derived from
System.Windows.Forms.Control. Both are different having few different
methods , properties and events. Like the data binding Event in ASP.NET
grid is public event EventHandler DataBinding;. but in Winforms when
you change the Datasource, DataSourceChanged event is called.

I hope it Helps

Regards,
Naveed Ahmad Bajwa
http://bajoo.blogspot.com/
 
Back
Top