Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

Converting data grid template control to DataBoundLiteralControl

I'm trying to access the text in a data grid template control which I'm able to do however the results that are returned have 25 characters around it.  The characters are not spaces as the trim function does not remove them.  My code is:
Public Sub dgProgramManager_Edit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgProgramManager.EditCommand
        Dim temp As String = CType(e.Item.Cells(3).Controls(0), DataBoundLiteralControl).Text
        Dim temp2 As String = Len(temp)
        dgProgramManager.EditItemIndex = e.Item.ItemIndex
End Sub

When I debug it the temp variable has the following content:
"             name           "
and the length is 29

The result should be just "name".

Any suggestions would be greatly appreciate.

Les
0
leskelly
Asked:
leskelly
1 Solution
 
kraffayCommented:
I think they are encoded spaces that .NET puts in the literal in order to center it.  Try to determine the ASCII code of characters with ASC function, and see if you can strip that out.
0
 
leskellyAuthor Commented:
For anyone else who enconunter this the ASCII codes are 13, 10 and 9.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now