0

这是我的代码:

Public Sub GridView1_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
    GridView1.EditIndex = e.NewEditIndex
    If Not IsPostBack Then
        GridView1.DataBind()
    End If
End Sub

Protected Sub GridView1_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GridView1.RowCancelingEdit
    GridView1.EditIndex = -1
End Sub

Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GridView1.RowUpdating
    Dim strid As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("idtxt"), TextBox).Text
    Dim strFirstName As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("fnmaetxt"), TextBox).Text
    Dim strLastName As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("lnametxt"), TextBox).Text
    Dim strAdress As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("adresstxt"), TextBox).Text
    Dim strEmail As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("emtailtxt"), TextBox).Text
    Dim strPhone As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("phonetxt"), TextBox).Text
    Dim strBirthday As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("birthdaytxt"), TextBox).Text


    x.updateProfile(strid, strFirstName, strLastName, strAdress, strEmail, strBirthday, strPhone)
    If Not IsPostBack Then
        GridView1.DataBind()
    End If
    GridView1.EditIndex = -1
End Sub

问题是我必须在编辑按钮上单击两次才能进入编辑模式,在取消按钮上单击两次才能返回编辑模式,当我更新时我必须重新单击更新才能返回编辑模式和当我重新单击它时,所有字段都变为空..

有什么帮助吗?

4

1 回答 1

0

您需要单击一次以获得焦点,然后再单击一次以实际执行编辑。我为这个问题所做的解决方法是在网格中处理 PreviewLeftMouseButton,我测试单击的元素是否是行元素,然后我将其聚焦并且我不声称要处理单击。

于 2013-08-20T10:05:48.133 回答