limit display to a certain number of characters...

indyB

Member
Joined
Mar 13, 2003
Messages
15
Ive got a page on which I want to display titles and then the first 50 characters of a description field called docText. The 50 character docText field will be used to link to a page which shows the entire description.

Heres the line if code where I currently display the description, but it displays the entire thing. This is where I need to somehow limit the output to the 50 characters. Any ideas out there? Thanks!

<wmx:HyperLinkField DataTextField="docText" SortExpression="docText" HeaderText="Description" DataNavigateurlField="id" DataNavigateUrlFormatString="comFaxDocs.aspx?id={0}"></wmx:HyperLinkField>
 
There might be an easier way to do this, but could you by chance put the Description inside a String, then display that String using the Substring method?

C#:
String desc = YourDescription;
if (desc.Length > 50)
   desc = desc.Substring(0, 50);
// Display desc.
 
Last edited by a moderator:
Code:
Dim desc As String = YourDescription
If desc.Length > 50 Then
   desc = desc.Substring(0, 50)
End If
Display desc.
 
Back
Top