Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum

CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Csla->telerik radGrid binding on AddNew - ideas?

    rated by 0 users
    This post has 4 Replies | 2 Followers

    Top 500 Contributor
    Posts 22
    mongo Posted: Tue, Jan 29 2008 12:29 PM

    I'm hoping someone can point me in the right direction.

    I have a telerik grid (under ASP.NET) configured on my page setup along with a CslaDataSource configured to my BusinessListBase derived class.  This has one level of objects in a collection of BusinessBase objects- nothing fancy here.

    When I click the "Add new item" item, I would hope that a new BusinessObject would get created and bound to for the initial value display.   I am hoping that I have the opportunity to load default values in the DataPortal. 

    I am not seeing anything that sticks out - I tried overriding the AddNewCore() method on the collection to see if the grid was making a call but nothing came through.  I'm guessing I'm probably missing something obvious here.

    Thank you,


    Top 10 Contributor
    Posts 9,475

    Web data binding doesn't normally end up invoking AddNewCore(), because they don't use IBindingList.

    Do you know what postback event occurs when you click "Add new item"? That is most likely where you'll need to put a bit of code to ask your collection for a new item - and you could call IBindingList yourself if that seems easiest - or implement some other public method on your collection that creates/adds a new item.


    Top 500 Contributor
    Posts 22
    mongo replied on Tue, Jan 29 2008 1:40 PM

    This makes perfect sense - an AddNew-style event is not readily apparent on the telerik control so I am pursuing this with telerik.  Once I have an approach, I'll post it here in case others are looking for the same behavior.

    Thank you

    Top 500 Contributor
    Posts 22
    mongo replied on Wed, Jan 30 2008 10:39 AM

    Thanks Rocky,

    The telerik article that deals with this is located here: http://www.telerik.com/help/aspnet/grid/grdInsertingValuesInPlaceAndEditForms.html

    If that link isn't available down the road, here is the general idea with Telerik:

    There are two events on the grid that you can hook - InsertCommand and ItemCommand.  The easiest command to hook is ItemCreated because it's far less noisy than ItemCommand.  In InsertCommand, you can test to see if the item in question is being inserted (as opposed to editing a pre-existing object) and assign a new business object to it.  If you have an inline or form based edit, you will get this command fired once for each element being rendered.  If you are using a custom control, you will see this event fired once for the control.  If you are using a custom control, you must float the "public object DataItem" property on your control to get the data object assigned for binding purposes.

    The code in the ItemCreated event looks something like this:

    if( e.Item.OwnerTableView.IsItemInserted )
        e.Item.DataItem = MyBusinessObject.CreateNewObject(...);

    You'll then need to adjust your CslaDataSource_UpdateObject(...) command to behave appropriately (insert vs. update).

    Thanks again,


    Top 500 Contributor
    Posts 22
    mongo replied on Wed, Jan 30 2008 1:17 PM

    I need to correct -

    You do not need to modify UpdateObject event on your datasource to handle Inserts and Updates.  The InsertObject event will be properly raised.

    Also,  the telerik Grid methods are ItemCreated and ItemCommand - as opposed to InsertCommand as I incorrectly stated earlier.

    Page 1 of 1 (5 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems