Hello,
I need to check if a cell that the user is editing (cell in edit mode) does not exist in the rest of the radgrid (for the same column).
Since radgrid1.Items retrieves just the items of the current page, I tried to disable paging and filtering for a while in the validation method raised by the OnServerValidate event.
That's ok, but rebinding creates some problems for me.
Take as example that the user inserts a value duplicated.
The OnServerValidate event occurs twice in sequence (I don't know why) and the second time it is raised the cell changed by the user has the original text before editing (in fact we did a rebind!) and my validation method evaluates that everything is ok and generates no error message and no change in the DB. The expected behaviour was that the user receives a message error: "Duplicate value".
Could you help me?
Is there a way to disable paging and filtering without rebinding the grid, but just refreshing the interface?
Following is the code.
Thanks in advance.
I need to check if a cell that the user is editing (cell in edit mode) does not exist in the rest of the radgrid (for the same column).
Since radgrid1.Items retrieves just the items of the current page, I tried to disable paging and filtering for a while in the validation method raised by the OnServerValidate event.
That's ok, but rebinding creates some problems for me.
Take as example that the user inserts a value duplicated.
The OnServerValidate event occurs twice in sequence (I don't know why) and the second time it is raised the cell changed by the user has the original text before editing (in fact we did a rebind!) and my validation method evaluates that everything is ok and generates no error message and no change in the DB. The expected behaviour was that the user receives a message error: "Duplicate value".
Could you help me?
Is there a way to disable paging and filtering without rebinding the grid, but just refreshing the interface?
Following is the code.
Thanks in advance.
| Public Sub ValidateDescriptionDuplicates(ByVal source As Object, ByVal args As ServerValidateEventArgs) |
| Dim desc As String |
| Dim id As String |
| Dim tb As New TextBox() |
| Dim hi As New System.Web.UI.HtmlControls.HtmlInputHidden() |
| Dim dvt As DataView |
| Dim dvr As DataRowView |
| Dim err As Integer |
| Dim e As DataGridItem |
| Dim dgi As GridDataItem |
| If Page.IsValid Then |
| dgi = Me.RadGrid1.EditItems(0) |
| Dim t As New Translate() |
| desc = MyRadUtility.GetControlValue(dgi, "textbox") |
| id = MyRadUtility.GetGridValue(dgi, "ID") |
| err = 0 |
| RadGrid1.AllowPaging = False |
| Dim filterExp As String = RadGrid1.MasterTableView.FilterExpression |
| RadGrid1.AllowFilteringByColumn = False |
| RadGrid1.Rebind() |
| For Each dgiTemp As GridDataItem In RadGrid1.Items |
| If desc = GetControlValue |
| dgiTemp, "label") And Not dgiTemp.GetDataKeyValue("ID") = id Then |
| If Not Me.Customvalidator2 Is Nothing Then |
| Me.Customvalidator2.Text = t.TranslateString("Attention! Description already inserted!") |
| End If |
| err = err + 1 |
| End If |
| Next |
| RadGrid1.AllowPaging = True |
| RadGrid1.AllowFilteringByColumn = True |
| RadGrid1.MasterTableView.FilterExpression = filterExp |
| RadGrid1.Rebind() |
| If err = 0 Then |
| args.IsValid = True |
| Else |
| args.IsValid = False |
| End If |
| Else |
| args.IsValid = True |
| End If |
| End Sub |