This is a migrated thread and some comments may be shown as answers.

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

1 Answer 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
CSurieux
Top achievements
Rank 2
CSurieux asked on 16 Oct 2009, 02:29 PM
Hello,

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.


Regards
CS

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Oct 2009, 06:56 AM
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.

JavaScript:
 
<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 
        } 
    }     
</script> 
Attach OnCommand event to RadGrid:
       <ClientEvents OnCommand="OnCommand" />

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

-Shinu.
Tags
Grid
Asked by
CSurieux
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or