Cant find the databind for data grid

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.
 
B

Bajoo

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/
 

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