views:

83

answers:

1

In a when there are no rows and user enter values and hit Enter after last value then new row is inserted (like it should be) But then the Delete button of the first row become the default button for the ListView and when user hit Enter on following rows first row in ListView is deleted.

I have tried to use surrounding both the ItemTemplates and the entire ListView. But it does not help.

Does anyone know how to solve this problme?

Also do you know how to make it work for the Edit row Also do you know how to make it work for Escape key, such that it fire cancel?

A: 

You can wrap specific content in an asp:Panel control and set the default button on that control. Could you use that control to wrap your insert row, and set the insert as the default button and take the default button property off the ListView?

Alternatively, could you add a jQuery event handler to the delete button, and if the character code matches the enter key then prevent that action?

if (window.event.keyCode == 13)
{
    event.returnValue=false;
    event.cancel = true;
}
Kyle B.