Formatting phone number of a DetailsView control

W

womblesjc

I have a data bound Details View control in asp.net 2.0 that formats a
phone number. The 'Default Mode' for the control is set to Edit. The
phone number field is a template field and I can successfully call a
function that formats the phone number when the control is filled. But
when updating, the value being passed in to my format function is
vbNull instead of the value in the phone number field of the control.
How can I get the update value to be the value of the phone number
field?
Here is the template field and formatting function. Thank You

<asp:TemplateField HeaderText="AltPhone" SortExpression="AltPhone"
ConvertEmptyStringToNull="False">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" MaxLength="14"
Text='<%# FormatPhoneNumber(DataBinder.Eval(Container.DataItem,
"AltPhone")) %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>

Public Function FormatPhoneNumber(ByVal strNumber As String) As String
Dim strTemp as String = strNumber

If strTemp.Length > 0 Then
strTemp = strTemp.Replace("(", "")
strTemp = strTemp.Replace(")", "")
strTemp = strTemp.Replace("-", "")
End If

Return strTemp
End Function
 
G

Guest

have you tried using a RegularExpressionValidator control to simply force the
user to enter the phone number in the required format. If you are not good
with regular expresions then there is a nice library at www.regexlib.com.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top