DataBinding In winforms .NET 3.5

Posts   
 
    
DelG
User
Posts: 18
Joined: 11-Jan-2007
# Posted on: 08-Sep-2008 16:13:15   

Hi all, I am trying to bind a DataGridView in a winforms APP, but I am getting no data. here is what I am doing.

I have a Entity Collection added to the form named "StopFlightCollection" which I dragged on from the tool box.

I have added a BindingSource called BsStopFlight and have set its datasource to the StopFlightCollection.

I have then set the DataGridView DataSource property to the BindingSource. The Grid gets the structure of the collection i.e all the correct columns appear but when i run the project the grid is blank no data. If I bind the grid from code e.g


    Public Shared Function GetFlightStopRules() As DataTable
        Return StopFlightCollection.GetMultiAsDataTable(Nothing, 0, Nothing)
    End Function

It all works fine, but thats not what I want. I am a bit of newbie to winforms so I know I am either doing something wrong or I am missing something. Also I have noticed that nothing appears in the DataMember dropdown for the bindingsource! is this why its not working.

Using the Latest Version of LLBL, VS2008, SQLServer 2005

Any Help would be great, thanks all. Jason

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 08-Sep-2008 16:42:20   

You just have to fetch the entityCollection.

Data won't be automatically fetched, unlike what happens in webapps and LLBLGenProDataSource (which automatically fetches data if LivePersistence is set to true).

DelG
User
Posts: 18
Joined: 11-Jan-2007
# Posted on: 08-Sep-2008 16:43:52   

Walaa wrote:

You just have to fetch the entityCollection.

Data won't be automatically fetched, unlike what happens in webapps and LLBLGenProDataSource (which automatically fetches data if LivePersistence is set to true).

Hi thanks for that. Any chance could eloborate on that for me? Where would I put that code?

Thanks for the help Jason

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 08-Sep-2008 16:56:14   

If you want the data loaded when you open the form then on Form_Load event otherwise anywhere else you want to load the data.

DelG
User
Posts: 18
Joined: 11-Jan-2007
# Posted on: 09-Sep-2008 16:12:21   

Walaa wrote:

If you want the data loaded when you open the form then on Form_Load event otherwise anywhere else you want to load the data.

Hi Thanks for the reply. I feel a bit silly but thanks to you I am saved simple_smile Thanks Jason