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
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