I have a radgrid using advanced databinding to connect to a linq to sql datasource. The grid allows the user to edit the data stored in a table in a sql database. One of the fields is a foreign key to another table. The grid will properly catch invalid values when editing a row and not allow the invalid value to be written to the database, however the invalid value still appears in the radgrid until the user clicks the grid's refresh button. This is a problem because the user see's invalid values saved to the grid even though they are not saved to the database.
Here is the code behind for the update command
The value that is causing the problem is the channelId. I have written code to check if the channel exists and display a popup if the channel doesn't exist. However, the grid still retains the invalid value.
Thanks in advance,
Jonathan Clark
Here is the code behind for the update command
Protected Sub RadGrid1_UpdateCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim ein = item.GetDataKeyValue("EIN").ToString()
Dim distributor = DbContext.Distributors.Where(Function(n) n.EIN = ein).FirstOrDefault()
item.UpdateValues(distributor)
Dim channel = DbContext.Channels.Where(Function(n) n.ChannelId = distributor.ChannelId).FirstOrDefault()
If channel Is Nothing Then
displayError("Distributor was not updated. Please enter a valid channelId.")
Else()
Try
DbContext.SubmitChanges()
Catch ex As Exception
displayError("Record cannot be updated")
End Try
End If
End Sub
The value that is causing the problem is the channelId. I have written code to check if the channel exists and display a popup if the channel doesn't exist. However, the grid still retains the invalid value.
Thanks in advance,
Jonathan Clark