Telerik VB Dynamic Data Field Templates - Decimal Edit - RadNumericTextBox
Here is a customFieldTemplate for Decimal Edit using VB and Telerik controls - RadNumericTextBox :
decimal_edit.ascx
<%@ Register assembly="Telerik.Web.UI"
namespace="Telerik.Web.UI" tagprefix="telerik" %>
<telerik:RadNumericTextBox
runat="server" ID="RadNumericTextBox1" Text='<%#
FieldValueEditString %>'
Skin="Vista"></telerik:RadNumericTextBox>
<asp:RequiredFieldValidator
runat="server" ID="RequiredFieldValidator1"
ControlToValidate="RadNumericTextBox1" Display="Dynamic"
Enabled="false" />
<asp:CompareValidator
runat="server" ID="CompareValidator1"
ControlToValidate="RadNumericTextBox1" Display="Dynamic"
Operator="DataTypeCheck" Type="Double"/>
<asp:RegularExpressionValidator
runat="server" ID="RegularExpressionValidator1"
ControlToValidate="RadNumericTextBox1" Display="Dynamic"
Enabled="false" />
<asp:RangeValidator
runat="server" ID="RangeValidator1"
ControlToValidate="RadNumericTextBox1" Type="Double"
Enabled="false" EnableClientScript="true" MinimumValue="0"
MaximumValue="100" Display="Dynamic" />
<asp:DynamicValidator
runat="server" ID="DynamicValidator1"
ControlToValidate="RadNumericTextBox1" Display="Dynamic"
/>
decimal_edit.ascx.vb
Imports System.Web.DynamicData
Partial Class Decimal_EditField
Inherits
System.Web.DynamicData.FieldTemplateUserControl
Public Overrides ReadOnly Property
DataControl As Control
Get
Return RadNumericTextBox1
End Get
End
Property
Protected Sub Page_Load(ByVal
sender As Object, ByVal e As EventArgs)
Dim metaData = MetadataAttributes.OfType(Of
System.ComponentModel.DataAnnotations.RangeAttribute)().FirstOrDefault()
If Not IsDBNull(metaData) Then
RadNumericTextBox1.MinValue =
Convert.ToDouble(metaData.Minimum)
RadNumericTextBox1.MaxValue =
Convert.ToDouble(metaData.Maximum)
End If
RadNumericTextBox1.ToolTip =
Column.Description
SetUpValidator(RequiredFieldValidator1)
SetUpValidator(CompareValidator1)
SetUpValidator(RegularExpressionValidator1)
SetUpValidator(RangeValidator1)
SetUpValidator(DynamicValidator1)
End Sub
Protected Overrides Sub ExtractValues(ByVal
dictionary As IOrderedDictionary)
dictionary(Column.Name) =
ConvertEditedValue(RadNumericTextBox1.Text)
End Sub
End Class
For a C# version of Telerik field
templates, see Atanas Korchev's blog,
Yet another update of RadControls for ASP.NET Ajax
DynamicData support.