Tips and tricks for .NET using ASP and VB code.

Trim extra spaces from DetailsView data

    Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.DataBound
If sender.CurrentMode = DetailsViewMode.Edit Then
For Each TrimDetailsViewRow As DetailsViewRow In sender.Rows
For Each TrimDataControlFieldCell As DataControlFieldCell In TrimDetailsViewRow.Cells
If TrimDataControlFieldCell.HasControls = True Then
For Each TrimControl As Control In TrimDataControlFieldCell.Controls
If TypeOf TrimControl Is TextBox Then
Dim TrimTextBox As TextBox = TrimControl
TrimTextBox.Text = Trim(TrimTextBox.Text)
End If
Next
End If
Next
Next
End If
End Sub

No comments:

Post a Comment

Search This Blog