I have the following code in a detail table ... the validation never happens... I also have the validation on the main table that works just fine.
Do you have an example of a validation when creating a record on a detail table
Do you have an example of a validation when creating a record on a detail table
<telerik:GridBoundColumn DataField="TAB" FilterControlAltText="Filter TAB column" HeaderText="Tab" SortExpression="TAB" UniqueName="TAB"> <ColumnValidationSettings EnableRequiredFieldValidation="True" RequiredFieldValidator-Text="Required - Tab" RequiredFieldValidator-ControlToValidate="TAB"> </ColumnValidationSettings> </telerik:GridBoundColumn> 4 Answers, 1 is accepted
0
Chris
Top achievements
Rank 1
answered on 13 Mar 2013, 07:59 PM
I have the same issue...
0
Princy
Top achievements
Rank 2
answered on 14 Mar 2013, 06:30 AM
Hi,
One suggestion is that you can add validator in edit mode dynamically as shown below.
C#:
Thanks,
Princy
One suggestion is that you can add validator in edit mode dynamically as shown below.
C#:
protected void grid_ItemCreated(object sender, GridItemEventArgs e){ if (e.Item is GridEditableItem && e.Item.IsInEditMode && e.Item.OwnerTableView.Name == "SampleErrorCauseTotal") { GridEditableItem item = (GridEditableItem)e.Item; GridTextBoxColumnEditor editor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor("EmployeeID"); TableCell cell = (TableCell)editor.TextBoxControl.Parent; RequiredFieldValidator validator = new RequiredFieldValidator(); editor.TextBoxControl.ID = "ID_for_validation"; validator.ControlToValidate = editor.TextBoxControl.ID; validator.ErrorMessage = "*"; cell.Controls.Add(validator); }}Thanks,
Princy
0
Chris
Top achievements
Rank 1
answered on 27 Mar 2013, 04:10 PM
Princy's solution does indeed add the validation, however for some reason, when trying to insert a new record in the Display table, the fields with the new validation added are not visible. And then, when clicking on the "Insert" link, the validation kicks in, and the fields become visible, with the validation message that was added in the code-behind.
Here's my (VB) code:
--------- UPDATE -------
I just found at that this is a bug that the Telerik team is working on.
http://feedback.telerik.com/Project/108/Feedback/Details/44766-the-auto-implemented-column-validation-functionality-of-radgrid-using-the-enabler
Here's my (VB) code:
Protected Sub RadGrid_InspectionLog_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid_InspectionLog.ItemCreated If TypeOf e.Item Is GridDataItem Then Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) Dim deleteBtn As LinkButton = DirectCast(item.FindControl("AutoGeneratedDeleteButton"), LinkButton) deleteBtn.Attributes.Add("onclick", "return confirm('Are you sure you want to delete row or record?')") End If 'Validation for the Details View table If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode And e.Item.OwnerTableView.Name = "ShipTable" Then Dim item As GridEditableItem = e.Item Dim edit_PONumber As GridTextBoxColumnEditor = item.EditManager.GetColumnEditor("PONumber") Dim cell As TableCell = edit_PONumber.TextBoxControl.Parent Dim validator As RequiredFieldValidator = New RequiredFieldValidator edit_PONumber.TextBoxControl.ID = "PONumber" validator.ControlToValidate = edit_PONumber.TextBoxControl.ID validator.ErrorMessage = "<br />This field is required" validator.ForeColor = Drawing.Color.Red cell.Controls.Add(validator) Dim edit_SNsShipped As GridTextBoxColumnEditor = item.EditManager.GetColumnEditor("SNsShipped") Dim cell2 As TableCell = edit_SNsShipped.TextBoxControl.Parent Dim validator2 As RequiredFieldValidator = New RequiredFieldValidator edit_SNsShipped.TextBoxControl.ID = "SNsShipped" validator2.ControlToValidate = edit_SNsShipped.TextBoxControl.ID validator2.ErrorMessage = "<br />This field is required" validator2.ForeColor = Drawing.Color.Red cell2.Controls.Add(validator2) End IfEnd Sub--------- UPDATE -------
I just found at that this is a bug that the Telerik team is working on.
http://feedback.telerik.com/Project/108/Feedback/Details/44766-the-auto-implemented-column-validation-functionality-of-radgrid-using-the-enabler
0
Hello,
Indeed the problem with validation of detail tables persists. This bug is already logged in our public feedback portal and you can follow its status here:
http://feedback.telerik.com/Project/108/Feedback/Details/44766-the-auto-implemented-column-validation-functionality-of-radgrid-using-the-enabler
Please excuse us for the inconvenience caused.
Greetings,
Pavlina
the Telerik team
Indeed the problem with validation of detail tables persists. This bug is already logged in our public feedback portal and you can follow its status here:
http://feedback.telerik.com/Project/108/Feedback/Details/44766-the-auto-implemented-column-validation-functionality-of-radgrid-using-the-enabler
Please excuse us for the inconvenience caused.
Greetings,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.