Is data binding correct approach?

Posts   
 
    
Posts: 254
Joined: 16-Nov-2006
# Posted on: 12-Mar-2007 17:16:15   

Guys,

Does anyone have any thoughts on whether data binding should be used in all cases and when other solutions such as simply providing code to perform updates / inserts of data captured on forms should be used.

I have a moderately complex example e.g. an Entity Employee contains some simple attributes e.g. Name / Address. This can be captured in a form view fine however an employee also has a list of ratings for each job area. E.g. job area against a number 1 - 7. This information should be captured in a grid view for an employee and map to a EmployeeJobRatingCollection object which is a property of an Employee containing EmployeeJobRating objects.

Again we could also have a number of other grids which contain details related to an employee. Should I use data binding for this solution and it seems difficult to achieve and awkward or go for some other approach?

Thoughts please?

Cheers

Matt

Aurelien avatar
Aurelien
Support Team
Posts: 162
Joined: 28-Jun-2006
# Posted on: 12-Mar-2007 17:46:33   

Hi,

I think you can use databinding for this kind of exemple. with ASP.NET 2 and LLBLGenProDataDource (with LLBLGenPro 2), witch works fine with gridview an formview.

Cheers,

Aurelien

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 12-Mar-2007 17:53:58   

You can always perform the Updates/Inserts manually in code without the 2-way databinding thing.

2-way DataBinding is not a must, it was made to make things easier for developers, so if you find it hard, complex or awkward to deal with in some situations, then don't use it, and go for whatever you are most compfortable with.

Posts: 254
Joined: 16-Nov-2006
# Posted on: 12-Mar-2007 20:50:27   

I know you can use gridview and formview together in data binding with LLBLGen entities as I've done this and the HnD source shows this a few times.

However in these cases the GridView shows a list of entities and the FormView shows a single entity. Here I need to show a single entity within a formview howevr I also need to nest another GridView within the FormView to show data for a single entity. This is where I'm confused as to how I'd used data binding to make this work.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 12-Mar-2007 21:23:59   

The same way you did before, the only difference is: now you'll use the SelectParameter of the LLBLGenProDataSource associated with the gridView to filter on the PK in the FormView.

Posts: 254
Joined: 16-Nov-2006
# Posted on: 13-Mar-2007 16:06:49   

Could you eloborate in more detail please?

Given this

I have a moderately complex example e.g. an Entity Employee contains some simple attributes e.g. Name / Address. This can be captured in a form view fine however an employee also has a list of ratings for each job area. E.g. job area against a number 1 - 7. This information should be captured in a grid view for an employee and map to a EmployeeJobRatingCollection object which is a property of an Employee containing EmployeeJobRating objects.

Then how should the nested form view and nested grid view be created. e.g. so the grid view shows all EmployeeJobRating objects using the JobRatings property of the employee. How would you use the PK in a select parameter to get this property information.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Mar-2007 19:51:41   

I think we are speaking about Master-Detail databinding scenario. Please check the following thread for details: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7029

Posts: 254
Joined: 16-Nov-2006
# Posted on: 14-Mar-2007 10:13:25   

Well master detail with a twist. This is master -> detail -> master -> detail.

i.e. the detail is in a formview with a nested grid view showing some of the detail for each record too.

I'll try a few things and probably post the code if I'm still having issues so you can review in more detail.