How can I format datagrid column as xxxxxx2345
I need to format a datagrid column for credit cards:
xxxxxxxxxxx2345 and still be able to edit the column.
What I tried was:
<asp:TemplateColumn HeaderText="DocumentNum">
<HeaderStyle HorizontalAlign="Center" ForeColor="White" BackColor="darkgreen" Wrap="false"></HeaderStyle>
<ItemStyle Wrap="false" />
<ItemTemplate>
<%#CheckLength(Container.DataItem("DocumentNumber" ))%>
</ItemTemplate>
</asp:TemplateColumn>
And
Protected Function CheckLength(ByVal DocumentNum As Object) As String
'I passed it as an object to stop the DBNull Error.
If DocumentNum.ToString().Length > 14 Then
Return "xxxxxxxxxx" & DocumentNum.SubString(5, 4)
Else
Return DocumentNum.ToString()
End If
End Function
I get an error that sustring as long not found.
The datatype for my field is bigint.
Thank you any help!
Thank you,
|