Link to home
Start Free TrialLog in
Avatar of rgh119
rgh119

asked on

DetailsView Field Scroll Bar

Is it possible to have one fo the fields in a DetailsView scroll when the data is too large to display.  i am currently using all "databound" fields.  I have a summary field that I would like to remain approximately 3-5 lines in hieght and a scroll bar appears when the data returned is larger than that amount of lines.
ASKER CERTIFIED SOLUTION
Avatar of GreymanMSC
GreymanMSC

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GreymanMSC
GreymanMSC

That will be a fixed height textbox.  To allow it to shrink if less than 5 rows, use the DetaiView's DataBound event.
    Protected Sub TheDetailsView_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles TheDetailsView.DataBound
        Dim T As TextBox = CType(sender, DetailsView).FindControl("txtDataField")
        If Not T Is Nothing Then
            Dim X As Integer = T.Text.Length \ T.Columns
            If X < 3 Then
                T.TextMode = TextBoxMode.SingleLine
                T.Height = New Unit(42, UnitType.Pixel)
            ElseIf X < 5 Then
                T.TextMode = TextBoxMode.SingleLine
                T.Height = New Unit((X + 1) * 14, UnitType.Pixel)
            Else
                T.TextMode = TextBoxMode.MultiLine
                T.Height = Nothing
                T.Rows = 5
            End If
        End If
    End Sub

Open in new window