Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
245
Add new row using roweditingtemplage
posted

I have this JavaScript code to add a new row using the rowEditingTemplate:

function addRow() {
var grid = $find("<%=grdMain.ClientID%>");
var row = grid.get_behaviors().get_editingCore().get_behaviors().get_rowAdding().get_row();
var ret = grid.get_behaviors().get_editingCore().get_behaviors().get_rowEditingTemplate();           
ret.enterEditMode(row);
}

When I use this for the button the edit window stays open <input type="button" name="AddRow" value="Add Row  " onclick="addRow()" />

When I use this for the button the edit window opens and closes immediately <asp:LinkButton ID="lnkAdd" runat="server" OnClientClick="addRow()">Add</asp:LinkButton>

I would prefer to use the link button because that is what our users are used too.

Is there a way to get the link button working?

Thanks, Pat

Parents
  • 1080
    Offline posted

    Hello Pat,

    Thank you for posting in our community.

    By default when the asp:LinkButton control is clicked it runs the function specified in the OnClientClick property and then makes a postback. This is the reason why the template closes. By returning false after the execution of the function the issue should be resolved:

     <asp:LinkButton ID="lnkAdd" runat="server" OnClientClick="addRow(); return false;">Add</asp:LinkButton>
     

Reply Children
No Data