This is a migrated thread and some comments may be shown as answers.

How to get the new value of edited cell?

2 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matias
Top achievements
Rank 1
Matias asked on 25 Sep 2014, 08:51 AM
Hello,

I am trying to prevent the user from using
negative values in two columns in my radgrid. I think that it might be easier for us to make a check in code behind.

We have made a method in code behind which should
get the value/values of the cells that has been edited by the user(only two
columns). And for some reason that method returns the old value, look below.

Example;

An order has a total price of 500 euro. If I change
this to 450 euro and push save changes then our method should print out 450
euro.. but it doesn’t. It prints out the first value of 500 euro which
frustrates me.

This method Is called using “onitemupdated” in the
radgrid

SubCheckFields(sender AsObject, e As Telerik.Web.UI.GridUpdatedEventArgs)

        Dim item
As
GridDataItem =TryCast(e.Item, GridDataItem)

        Dim
itemValue AsString= item("Quantity").Text

       
MsgBox(itemValue)

        EndSub

I want to make a check in our method to see if the
value is negative or not.. if negative it shouldn’t save anything and just show
a message to the user.. if the edited value is positive

It should save the changes.

 

So basically we need;

When the save changes is pressed it should;

1.  Call the method in the code-behind.
2.  Check if some of the values in the two colums are negative.
3.  If negative – Abort/error message
4.  If positive – Save changes

Furthermore it shouldn’t use the aspx
Updatecommand (since we use the code behind), how do we turn off this?

Also, is there an easier way to do this?

Code: code

Kind Regards

2 Answers, 1 is accepted

Sort by
0
Matias
Top achievements
Rank 1
answered on 25 Sep 2014, 12:04 PM
Or maybe there is a way to use Javascript in some way?

maybe the clientevent "onBatchEditClosed" could check the new value if its less than 0? if its less than zero it should make a pop up warning the user.. and if its higher than zero it shouldnt alert the user at all.


Kind Regards
0
Matias
Top achievements
Rank 1
answered on 25 Sep 2014, 02:27 PM
I fixed this by using javascript.
Tags
Grid
Asked by
Matias
Top achievements
Rank 1
Answers by
Matias
Top achievements
Rank 1
Share this question
or