EditableRootList in asp.net

EditableRootList in asp.net

Old forum URL: forums.lhotka.net/forums/t/2986.aspx


Blarm posted on Tuesday, June 05, 2007

Does anyone have a quick example of using an EditableRootList with an updatable grid in asp.net code.

I can't quite work out the code for the CSLADatSource_SelectObject, UpdateObject, InsertObject and DeleteObject.

Thanks,

Bill 

RockfordLhotka replied on Wednesday, June 06, 2007

Hmm, it isn't really designed for the web - I created it to support a scenario for Windows Forms (and now WPF).

However, it should work in the web as long as you keep it in session.

The SelectObject would be like any other collection - no difference there.

But the Update/Insert/Delete handlers would be different. You need to

  1. Get the list from Session
  2. Locate the index of the item to be saved
  3. Update that object with values from data binding (or mark it as deleted)
  4. Call theList.SaveItem(index)
  5. Rebind the UI to the list (because step 4 may have changed that item)

 

Blarm replied on Thursday, June 07, 2007

Rocky, thanks for the reply.

I have just tried a simple test using Delete and the DataSource_Delete handler is not firing when I delete from the grid.

I have debugged this and the CanDelete Property in CslaDataSourceView is returning False:

    Public Overrides ReadOnly Property CanDelete() As Boolean
      Get
        If GetType(Csla.Core.IUndoableObject).IsAssignableFrom( _
          CslaDataSource.GetType(mTypeAssemblyName, mTypeName)) Then
          Return True
        Else
          Return False
        End If
      End Get
    End Property

The code is the same for the CanInsert and CanUpdate.

Do you have any idea of how I could work around this.

Thanks,

Bill

 

 

RockfordLhotka replied on Friday, June 08, 2007

Hmm, that’s an interesting issue that I hadn’t thought about…

 

Obviously ERLB isn’t undoable itself. I wonder, however, if the check shouldn’t be a little broader. I should be able to see if IBindingList is implemented, and if so I can get the true/false answer from that interface.

 

Something to add to the to-do list.

 

Rocky

 

 

From: Blarm [mailto:cslanet@lhotka.net]
Sent: Thursday, June 07, 2007 12:09 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] EditableRootList in asp.net

 

Rocky, thanks for the reply.

I have just tried a simple test using Delete and the DataSource_Delete handler is not firing when I delete from the grid.

I have debugged this and the CanDelete Property in CslaDataSourceView is returning False:

    Public Overrides ReadOnly Property CanDelete() As Boolean
      Get
        If GetType(Csla.Core.IUndoableObject).IsAssignableFrom( _
          CslaDataSource.GetType(mTypeAssemblyName, mTypeName)) Then
          Return True
        Else
          Return False
        End If
      End Get
    End Property

The code is the same for the CanInsert and CanUpdate.

Do you have any idea of how I could work around this.

Thanks,

Bill

 

 



Copyright (c) Marimer LLC