Hi All
I have a RadGrid that uses the standard edit mode form, and I am try to complete
the validation as in the declaration shown below:
The problem is that when the MaxLength property is set it prevents any chacters being entered in Edit mode. Insert Mode is OK
So I took that property out and used code behind like this:
But that did not have any effect at all.
What I am doing worng here?
Thanks
Clive
PS using Q2 2009 version
I have a RadGrid that uses the standard edit mode form, and I am try to complete
the validation as in the declaration shown below:
<telerik:GridTemplateColumn DataField="FirstName" |
HeaderText="FirstName" SortExpression="FirstName" |
UniqueName="FirstName"> |
<EditItemTemplate> |
<asp:TextBox ID="FirstNameTextBox" runat="server" |
Text='<%# Bind("FirstName") %>' MaxLength="25"> |
</asp:TextBox> |
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" |
runat="server" |
ControlToValidate="FirstNameTextBox" |
Display="Dynamic" |
ErrorMessage="First name required" |
SetFocusOnError="True"></asp:RequiredFieldValidator> |
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" |
runat="server" Display="Dynamic" |
ErrorMessage="Illegal characters" |
SetFocusOnError="True" |
ValidationExpression="^[a-zA-Z0-9 \-]+$" ControlToValidate="FirstNameTextBox"></asp:RegularExpressionValidator> |
</EditItemTemplate> |
So I took that property out and used code behind like this:
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) |
If TypeOf e.Item Is GridDataItem Then |
Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem) |
Dim txtbx As TextBox = DirectCast(dataItem.FindControl("FirstNameTextBox"), TextBox) |
Dim strtxt As String = txtbx.Text |
If strtxt.Length > 25 Then |
txtbx.Text = strtxt.Remove(25) |
End If |
End If |
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then |
Dim editItem As GridEditableItem = DirectCast(e.Item, GridEditableItem) |
Dim txtbx1 As TextBox = DirectCast(editItem.FindControl("FirstNameTextBox"), TextBox) |
Dim strtxt1 As String = txtbx1.Text |
If strtxt1.Length > 25 Then |
txtbx1.Text = strtxt1.Remove(25) |
End If |
End If |
End Sub |
But that did not have any effect at all.
What I am doing worng here?
Thanks
Clive
PS using Q2 2009 version