Protected Sub DetailsView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.PreRender
If sender.CurrentMode <> DetailsViewMode.ReadOnly Then
If sender.Rows.Count > 0 Then
Do
For i As Integer = sender.Rows.Count - 1 To 0 Step -1
Dim LastDetailsViewRow As DetailsViewRow = sender.Rows(i)
If LastDetailsViewRow.Cells.Count > 0 Then
For j As Integer = LastDetailsViewRow.Cells.Count - 1 To 0 Step -1
Dim LastDataControlFieldCell As DataControlFieldCell = LastDetailsViewRow.Cells(j)
If TypeOf LastDataControlFieldCell Is DataControlFieldCell Then
If TypeOf LastDataControlFieldCell.ContainingField Is BoundField Then
Dim LastBoundField As BoundField = LastDataControlFieldCell.ContainingField
If LastBoundField.Visible = True Then
If LastDataControlFieldCell.HasControls = True Then
Dim LastControl As Control = LastDataControlFieldCell.Controls(0)
If TypeOf LastControl Is TextBox Then
Dim LastTextBox As TextBox = LastControl
MaintainScrollPositionOnPostBack = False
'Set the cursor to the last text box so the whole details view will be visible.
SetFocus(LastTextBox)
'The reason for the Do loop is to exit out of both For loops at the same time.
Exit Do
End If
End If
End If
End If
End If
Next j
End If
Next i
Exit Do
Loop
End If
End If
End Sub
Tips and tricks for .NET using ASP and VB code.
Set focus to last TextBox in DetailsView so all fields will be visible in browser
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment