5 Replies - 2523 Views - Last Post: 29 December 2013 - 10:32 PM Rate Topic: -----

#1 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1048
  • View blog
  • Posts: 4,075
  • Joined: 02-July 08

Double click Edit button.

Posted 28 December 2013 - 12:54 PM

I have a GridView with the Edit Button for editing which works, just makes me click it twice before it goes into Edit Mode. Does anyone know why this would be? I am using ItemTemplates and EditItemTemplates in the columns - using BoundFields changed nothing. Let me know if I can show you anything - code or html.

Private Sub gvClients_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvClients.RowCommand
    Dim row = CInt(e.CommandArgument.ToString)
    If e.CommandName = "Edit" Then
      gvClients.EditIndex = row
    End If


Edit: some more info...

This post has been edited by _HAWK_: 28 December 2013 - 07:32 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Double click Edit button.

#2 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3354
  • View blog
  • Posts: 11,354
  • Joined: 12-December 12

Re: Double click Edit button.

Posted 28 December 2013 - 03:13 PM

I don't know much about this but.. I don't believe EditIndex is intended to be used in this way. The linked page describes circumstances when EditIndex is used.

I suspect that you don't need the If, the CommandName of "Edit" should be enough to take it into Edit mode.

http://msdn.microsof...(v=vs.110).aspx
Was This Post Helpful? 0
  • +
  • -

#3 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1048
  • View blog
  • Posts: 4,075
  • Joined: 02-July 08

Re: Double click Edit button.

Posted 28 December 2013 - 06:29 PM

I took that out and it still makes me click it twice.


Quote

You can programmatically put a row in edit mode by setting the EditIndex property with the index of the row. To programmatically exit edit mode, set the EditIndex property to -1.


MSDN reference

Regardless whether I call that or not with the RowCommand event it still makes me click them twice - yes all of them Edit Update Cancel

This post has been edited by _HAWK_: 28 December 2013 - 06:49 PM

Was This Post Helpful? 0
  • +
  • -

#4 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 620
  • View blog
  • Posts: 2,772
  • Joined: 03-December 12

Re: Double click Edit button.

Posted 29 December 2013 - 12:02 PM

I don't know if it is feasible to select a row on hover, but I believe the first click is selecting the row and the second is actually for the button. I have had the same issue updating text fields in gridview.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3354
  • View blog
  • Posts: 11,354
  • Joined: 12-December 12

Re: Double click Edit button.

Posted 29 December 2013 - 12:26 PM

The only other thing I would suggest to try is still to remove this line:

gvClients.EditIndex = row

and use the RowEditing event.

Quote

Occurs when a row's Edit button is clicked, but before the GridView control enters edit mode.

Protected Sub TaskGridView_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs)
    'Set the edit index.
    TaskGridView.EditIndex = e.NewEditIndex
  End Sub

Was This Post Helpful? 0
  • +
  • -

#6 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1048
  • View blog
  • Posts: 4,075
  • Joined: 02-July 08

Re: Double click Edit button.

Posted 29 December 2013 - 10:32 PM

This is what I needed:

Private Sub gvClients_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvClients.RowCommand
    Dim row = CInt(e.CommandArgument.ToString)
    If e.CommandName = "Edit" Then
      gvClients.EditIndex = row
      BindData()
    End If
End Sub


Thanks for you help!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1