这是我的代码:
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
问题是我必须在编辑按钮上单击两次才能进入编辑模式,在取消按钮上单击两次才能返回编辑模式,当我更新时我必须重新单击更新才能返回编辑模式和当我重新单击它时,所有字段都变为空..
有什么帮助吗?