How to add a new record clientside without staying in edit mode

2 posts, 0 answers
  1. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 16 Oct 2009 Link to this post


    I need to add a new record with default values each time the user click on add new record, without staying in edit mode, what is the best method.

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Oct 2009 Link to this post

    Hi Christia,

    One suggestion would be invoking an ajaxRequest when clicking "Add New Record" button and handle adding the row from the code-behind server side handler. Also cancel the OnComand event in order to prevent showing insertitem.

    <script type="text/javascript"
        function OnCommand(sender, args) {        
            if (args.get_commandName() == "InitInsert") { 
                args.set_cancel(true);  //Cancel the event 
                $find("<%=AjaxManager1.ClientID%>").ajaxRequest(arguments); // Call ajaxRequest 
    Attach OnCommand event to RadGrid:
           <ClientEvents OnCommand="OnCommand" />

     private void RadAjaxManager1_AjaxRequest(object  sender, AjaxRequestEventArgs e) 
     //code to add new row 

Back to Top