Forcing Default button on a gridview

后端 未结 2 1968
清歌不尽
清歌不尽 2021-01-06 20:32

I\'m using gridview with templates to show and edit some information from a sql database.

When I edit and change the data in that row and then click enter it automat

2条回答
  •  梦毁少年i
    2021-01-06 21:03

    I had a similar problem and I found a very simple workaround:

    1. Place a button below the GridView and make it invisible by CSS (i.e. position: relative; left: -2000px)
    2. Create a Panel around the GridView and give it as DefaultButton the ID of the button we just created.
    3. Write the following line of code for the click-event of the button: myGridView.UpdateRow(myGridView.EditIndex, false);

    Whenever you press enter in the GridView now, the edited row will be confirmed.

提交回复
热议问题