Fire init insert command with empty datasource

4 posts, 1 answers
  1. Vincent Kemp
    Vincent Kemp avatar
    3 posts
    Member since:
    Feb 2009

    Posted 13 Jan 2015 Link to this post

    Hi,

    Is it possible to fire the "init insert" command when there are no rows in the coupled datasource of the dataform object?

    For now I created a button and in it's click event I put the following code:

    Radform1.Items(0).FireCommandEvent("InitInsert", "")

    But when the coupled datasource has no rows, it fails (because of the empty itemscollection).

    Is there a workaround for inserting the "first row"?

    Regards
  2. Daniel
    Daniel avatar
    2 posts
    Member since:
    May 2014

    Posted 14 Jan 2015 Link to this post

    I also have the same problem. I got a button outside the raddataform to fire the InitInsert command and it doest work.
    Does someone have any solutions?
    Thanks a lot

    protected void lbtAdd_Click(object sender, EventArgs e)
    {
        int siteId = GetPageSiteID();
        //TODO - show form - insert new
        RadDataFormItem item = RadDataForm1.Items[0];
        item.FireCommandEvent("InitInsert", "");
     
    }
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 16 Jan 2015 Link to this post

    Hi,

    I have built a sample project where the functionality is implemented. In addition there is a RadButton control placed outside of the RadDataForm that can be used to show the insert item.

    The sample is attached to this post. Try using similar approach and you should be able to implement the functionality you are looking for.

    Regards,
    Viktor Tachev
    Telerik
  5. Vincent Kemp
    Vincent Kemp avatar
    3 posts
    Member since:
    Feb 2009

    Posted 16 Jan 2015 Link to this post

    Thanks for your response. Put the button in the "emptydatatemplate" is a perfect workaround for my problem.

    My first idea was to use a "create new" button outside the raddataform (in the toolbar for example) and fire the event. That's not possible with a empty list (I guess) perhaps in a later version.
Back to Top