Creating a LongTextField

None of the existing GridView fields do a good job of handling large amounts of text. You can fix this problem by creating a custom field, named the LongTextField, which you can use to display the value of text columns regardless of the length of the text.

In normal display mode, LongTextField displays the text in a scrolling <div> tag. In edit display mode, the text appears in a multiline TextBox control (see Figure 11.23).

Figure 11.23. Displaying a long text field.

image

To create a custom field, a new class must be inherited from the base BoundField control. The custom LongTextField is contained in Listing 11.31.

Listing ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.