C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

Limit Column VB.NET Version


Posted Date: 25 Nov 2004    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: AbiBaby (Abishek Bellamkonda)Member Level: Gold    
Rating: 1 out of 5Points: 4



http://www.dotnetspider.com/technology/KBPages/964.aspx

Imports System.Web.UI.WebControls

Public Class LimitColumn
Inherits BoundColumn

Public CharacterLimit As Integer = 0
Protected Overrides Function FormatDataValue(ByVal dataValue As Object) As String
Return Truncate(dataValue.ToString(), CharacterLimit)
End Function
Public Function Truncate(ByVal input As String, ByVal characterLimit As Integer) As String
Dim output As String = input

' Check if the string is longer than the allowed amount
' otherwise do nothing
If output.Length > characterLimit And characterLimit > 0 Then
' cut the string down to the maximum number of characters
output = output.Substring(0, characterLimit)
' Check if the character right after the truncate point was a space
' if not, we are in the middle of a word and need to remove the rest of it
If input.Substring(output.Length, 1) <> " " Then
Dim LastSpace As Integer = output.LastIndexOf(" ")
' if we found a space then, cut back to that space
If LastSpace <> -1 Then
output = output.Substring(0, LastSpace)
End If
End If
' Finally, add the "...", telling user that there is more text
output += "..."
End If
Return output
End Function
End Class




Responses

Author: Asar Imhotep    31 Oct 2005Member Level: Bronze   Points : 0
Is there an actual page I can see the full code? It seems not to be working and I don't know if I am putting the code in the right place. I am using VB. Can someone help me out? Thanks in advance.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Convert string to Date
Previous Resource: Performance Tuning in ASp.Net
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use