CodeSmith Community
Your Code. Your Way. Faster!

Using UltraWebGrid with .netTiers

Latest post 09-07-2007 10:34 AM by bgjohnso. 4 replies.
  • 03-24-2007 1:36 PM

    • Lusid
    • Not Ranked
    • Joined on 02-04-2007
    • Posts 8
    • Points 130

    Using UltraWebGrid with .netTiers

    Hey everyone,

    I know there are a lot of mixed feelings/experiences using the Infragistics controls with .netTiers on these forums, but there really isn't any demonstrated examples of how (if possible) to make all of it work together.

    I am trying to create a simple UltraWebGrid that uses a TypedDataSource. Selecting, sorting, filtering, etc all work great. However, I can't figure out for the life of me how to make the thing insert/update/delete. With a typical ObjectDataSource connected to a POCO or DataSet, it calls the methods on postback and takes care of it. I was assuming this is how the TypedDataSources would work too with the entity classes, but that doesn't seem to be the case. It seems that the .netTiers web library is more of a single update at a time concept while the Infragistics grid goes through and does all the updates at once, but I'm really quite oblivious to the magic that is happening behind the scenes, so it is all quite a mystery to me at this point. I've tried the Typed Data Sources, EntityDataSource, regular .NET ObjectDataSource (attached to the Service layer classes), etc. All seem to have their own strange issues.

    Has anyone gotten the UltraWebGrid control to work (select/insert/update/delete) with the TypedDataSources? Or even gotten it to work at all with .netTiers. I really don't want to have to pick between .netTiers or Infragistics controls... I love them both too much. I just want to find a solution to make them work together nicely.

    Even the slightest shove in the right direction would be extremely helpful. At this point, I'm pretty much desperate. I feel I've tried every combination up to this point with no success.

    Thanks,
    Marc

    • Post Points: 5
  • 03-24-2007 3:26 PM In reply to

    • Lusid
    • Not Ranked
    • Joined on 02-04-2007
    • Posts 8
    • Points 130

    Re: Using UltraWebGrid with .netTiers

    Alright, from what I can tell, when using the Typed Data Sources, adding new records works as expected without any additional code. The updates and deletes required special handlers... here's what I had to do.

        protected void UltraWebGrid1_UpdateRowBatch(object sender, RowEventArgs e)
        {
            if (!(e.Row.Cells.FromKey("Id").Value is Int64)) return;

            MyService service = new MyService();
            MyEntity entity = service.GetById(
                (long)e.Row.Cells.FromKey("Id").Value);

            Hashtable hash = new Hashtable();
            foreach (UltraGridCell cell in e.Row.Cells)
            {
                hash.Add(cell.Key, cell.Value);
            }

            MyDataSource.Update(entity, hash);
        }

        protected void UltraWebGrid1_DeleteRowBatch(object sender, RowEventArgs e)
        {
            MyService service = new MyService();
            MyEntity entity = service.GetById(
                (long)e.Row.Cells.FromKey("Id").Value);

            MyDataSource.Delete(entity);
        }

    This explicitly updates and deletes rows as needed for the batched updates/deletes that the grid sends on postback. The first line in the update batch routine... I'm still not sure why it is needed, but if you don't have it, it can cause your transaction to be rolled back because it sends an extra update occasionally (with some random objects as cell values... yikes). So, I just made sure that the Id cell matches the entity Id type before continuing with the update. Everything else here is fairly self explanatory.

    Hopefully, this will help someone... and hopefully, someone will tell me there is a better way! Geesh.

    Thanks,
    Marc

    • Post Points: 5
  • 03-24-2007 3:29 PM In reply to

    • Lusid
    • Not Ranked
    • Joined on 02-04-2007
    • Posts 8
    • Points 130

    Re: Using UltraWebGrid with .netTiers

    One last note... using this method, I successfully was able to remove (not hide, but actually remove) all of the extra columns that Infragistics sees when it binds to the data source. You only need bindings to the primary keys and the fields you want to be allowed. Everything else is optional. Smile

    • Post Points: 35
  • 09-07-2007 8:50 AM In reply to

    • evali
    • Top 500 Contributor
    • Joined on 12-15-2005
    • Posts 9
    • Points 135

    Re: Using UltraWebGrid with .netTiers

    I'm new to UltraWebGrid. When I tried to bind my Tlist<myclass> to UltraWebGrid. It does not work. The following exception occurred at class ListBase<T>:

    System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown:

    Line 609:         foreach (T Item in this)
    Line 610:         {
    Line 611:            s += Item.ToString() + System.Environment.NewLine;
    Line 612:         }
    Line 613:         return s;

    Do you have any idea why this is happening? Or could you share with me how to bind TList<> to UltraWebGrid? I don't know how to specify the column name from my data source.

    Thanks!

    Eva

    • Post Points: 35
  • 09-07-2007 10:34 AM In reply to

    • bgjohnso
    • Top 10 Contributor
    • Joined on 09-15-2005
    • Spokane, WA
    • Posts 764
    • Points 22,530

    Re: Using UltraWebGrid with .netTiers

    Hi Eva,

    The code you show above is in the ToString method of the TList.  How many records are in your list?  This code should probably be converted to use StringBuilder rather than just appending immutable strings together.  I can definitely see where you could have a memory issue if your list contains a large number of items since it is calling ToString on every item in the list (especially if the items in the list have a large number of properties).  I'm also not sure why the UltraWebGrid would be calling ToString on the List in the first place...

    Here are a couple of post regarding netTiers and Infragistics.

     http://community.codesmithtools.com/forums/p/5584/22070.aspx#22070

    http://community.codesmithtools.com/forums/p/5656/22246.aspx

     

    Ben Johnson
    ------------------------------
     Member of the .NetTiers team
     Visit http://www.nettiers.com
    ------------------------------

    • Post Points: 5
Page 1 of 1 (5 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems