vb.nettelerikradgrid

Setting the value of a GridEditableEitem


I have a RadGrid on which I'm doing validation of inserted/edited records. I get the existing values, if any, with SavedOldValues and the edited ones with OwnerTableView.ExtractValuesFromItem so I can perform the validation.

But for one particular field, if the value is below a certain threshold, or blank, then I want to change it to the minimum, with no need to tell the user. How can I do that?

I'm using this code:

Dim item As GridEditableItem = e.Item, values As New Hashtable 'e is from GridCommandEventArgs
rgRadGrid1.MasterTableView.ExtractValuesFromItem(values, item)
Dim w As Integer
If Not Integer.TryParse(values("Weight"), w) Then
    w = 0
End If
If w < minWeight Then item.[what do I put here?] = minWeight.ToString

Solution

  • The answer I have found is apparently no answer exists. This I have found from this page: https://www.telerik.com/forums/grideditableitem-updatevalues-problem-with-gridmaskedcolumn

    It specifically says:

    You can not directly change the value.

    So even trying to use item.UpdateValues(values), which doesn't seem to do anything at all, the textbox values remain unchanged.

    I'm solving my specific problem in an unsatisfactory, yet workable, way: passing my single updated value I want to check to the validation code. This would suck to use if I had to allow prior editing of any of the other fields to check, but in my case I don't. If I did, I suppose I could pass an additional object with all of the potentially edited values in them, but it seems like an unnecessary variable, only needed because I can't edit the GridEditableItem itself.

    So my updated code simply passes w to the ValidateRouteInfo method I had. I also had to add this unnecessary variable to the Edit method which also calls ValidateRouteInfo, and put in the edited weight.