SubSonic Forums
All Your Database Are Belong To Us

2.1 Collections and DataBinding

Latest post 10-01-2008 3:29 AM by GeoffAtDatagaard. 6 replies.
  • 05-24-2008 12:46 PM

    2.1 Collections and DataBinding

    Im using Subsonic 2.1 (SVN - Revision 442) and VS 2005 VB.NET.

    I decided to convert my (work in progress) framework from 2.0.3 to 2.1 and switch to repository pattern in the process.

    2.0.3 collections were a snap to bind, but Im having problems getting 2.1 repository collections to bind.

    No errors are raised and if I inspect the the collection it has the right data, but after binding to a grid by either bindingsource or directly to the grid's datasource... nothing. I can however bind succesfully to a Collection.ToDataTable. Can anyone provide me with any clues?

    While Im on the subject of collections,  I would be interested in hearing other's views on something.

    Ive seen a couple of discussions in the past on the fact that collections do not persist deletions to the database during a saveall. I stand corrected, but I believe that is a moot point with repository collections as they dont have save methods anyway. Im just wondering what others are doing with regards saving collection data back to the DB. Because of the deletion issue I described above, I built a generic RowsSaver class (thingy) that basically processes each row in a collection and sends the appropriate insert/update/deletes to the database. It works and at the moment I just plan on revising this class in my 2.1 version. But Ive always thought there should be an easier way, its not uncommon for me to overlook the obvious Embarrassed 

    Ive played with using a data table to do the persisting, but that just generated more headaches and seemed kind of counterproductive. Any thoughts ?

    BTW has anybody else found that the search facility in the newlook forums isnt working to good ?

     

  • 05-25-2008 3:56 PM In reply to

    • DanKline
    • Top 50 Contributor
    • Joined on 12-13-2006
    • West Bend, WI
    • Posts 46

    Re: 2.1 Collections and DataBinding

     Hi Geoff,

    I hope I understand clearly.  I've been working with 2,1.3 and have seen consitent errors on Update/Save.  All retrieval seems to work flawlessly, but I was unable to post any changes back to the SQL tables.  The SQL SET command section appeared to not be populated which resulted in an SQL syntax error.  I'm going to open the issue at Codeplex.  For now, I'm using 2.0.3.

     

    If you're going to look back and laugh... You might as well laugh now!

  • 05-25-2008 11:18 PM In reply to

    Re: 2.1 Collections and DataBinding

     Thanks for the response Dan.

    Im not sure we are talking about the same issue.

    My problem relates to binding repository based collections to winform controls. I dont have any problems updating back to the database. Im just stuck with binding to datatables at the moment, though Im finding some advantages with this approach anyay particularly when it comes to using the errorprovider, so I may yet elect to continue using datatables for all of my databinding.

    My point was that in 2.0.3 I could bind to a collection class in the designer and get my grid populated with the columns. Then at runtime I pointed  the datasource to a populated collection and it all just worked. My experience in 2.1 has been that binding to the collection class in the VS designer does not populate the control with columns and setting the datasource at runtime does not populate the control with data.

    I suspect I am missing something as nobody else seems to be reporting this issue, but I dont know what else to try.

     

     

     

  • 05-25-2008 11:38 PM In reply to

    • DanKline
    • Top 50 Contributor
    • Joined on 12-13-2006
    • West Bend, WI
    • Posts 46

    Re: 2.1 Collections and DataBinding

     Thanks.  I've since resolved the issue I was having with database update.  I haven't had the issue you explain.  My Dropdowns are populated with collections.  I manually configure the Column on the grids, but if I don't, the table columns are used.

    I'm binding to a BindingSource which is Bound to the collection, which if I understnd it is the preferered Microsoft approach to Binding dataGridViews.

    My strategy is like this:
    Orion.LZLinkCollection lzcol = new InlineQuery()
         .ExecuteAsCollection<Orion.
    LZLinkCollection>
         (
    "SELECT * from dbo.LZLinks WHERE RFDevice = @RFDevice", DevItem)
    // Bind 'em up
    LZoneBinding.DataSource = lzcol;
    cbLZone.DataSource = LZoneBinding;
    cbLZone.DisplayMember =
    "LZoneNum";

     

    If you're going to look back and laugh... You might as well laugh now!

    Filed under: , ,
  • 05-26-2008 12:27 AM In reply to

    Re: 2.1 Collections and DataBinding

    Reply |Contact |Answer

     OK, it seems the form I was using for testing got screwed up ??

    After deleting all datasources and databound controls from the form I was able to bind as expected Big Smile

     

     

  • 10-01-2008 3:18 AM In reply to

    • ptutt
    • Not Ranked
    • Joined on 09-26-2008
    • Posts 4

    Re: 2.1 Collections and DataBinding

    I get the exact behaviour.  Create the object datasource based on the collection class and try to databind it to a grid but the column information is not available.  I am using the ActiveRecord base class.  I have tried starting a new project, but I get the same behaviour.  What is the fix for this???

  • 10-01-2008 3:29 AM In reply to

    Re: 2.1 Collections and DataBinding

    There was a problem (since fixed in the SVN) in the templates that caused this.

    http://forums.subsonicproject.com/forums/p/3525/14438.aspx#14438

     

Page 1 of 1 (7 items) | RSS