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
Dim MaxColumnWidth As New Int64
If TypeOf TrimDataControlFieldCell.ContainingField Is BoundField Then
Dim WidthBoundField As BoundField = TrimDataControlFieldCell.ContainingField
Dim WidthFieldName As String = WidthBoundField.DataField
If TypeOf sender.DataItem Is Data.DataRowView Then
Dim WidthDataRowView As Data.DataRowView = sender.DataItem
Dim WidthDataView As Data.DataView = WidthDataRowView.DataView
Dim WidthDataTable As Data.DataTable = WidthDataView.Table
Dim WidthColumn As Data.DataColumn = WidthDataTable.Columns(WidthFieldName)
MaxColumnWidth = WidthColumn.MaxLength
End If
End If
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)
If IsDate(TrimTextBox.Text) = True Then
MaxColumnWidth = 27
End If
If MaxColumnWidth > 0 Then
If MaxColumnWidth > 253 Then
TrimTextBox.Width = New WebControls.Unit("97%")
Else
TrimTextBox.Width = New WebControls.Unit(MaxColumnWidth + 2 & "ex")
End If
End If
End If
Next
End If
Next
Next
End If
End Sub
Tips and tricks for .NET using ASP and VB code.
Adjust DetailsView edit TextBox widths to fit data definition
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment