1
如何設置聚焦到特定的控制在一個DataGridView行單擊編輯按鈕後?當網格綁定時,我可以爲它做一個新行,但不能用於現有的行。控制似乎還沒有存在。ASP.net - 將焦點設置到編輯行
'這行不通(現有行)
Protected Sub gvDays_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs) Handles gvDays.RowEditing
Try
gvDays.EditIndex = e.NewEditIndex
gvDays.Rows(e.NewEditIndex).FindControl("txtDayText").Focus()
Catch ex As Exception
Helper.WriteException(ex)
End Try
End Sub
' 這不工作的新綁定行
Private Sub gvDays_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvDays.RowDataBound
If e.Row.RowState = DataControlRowState.Edit Then
e.Row.Cells(3).Controls(0).Focus()
End If
End Sub