I have
a RadGridView and with one button I command that everything in the column seven change
of update to 5 and nothing happens, the value is not updated, I have
tried many ways to solve this but I could not. I read this :
Before the value is set RadGridView.Validating event is fired. This event could be canceled to prevent updating the value in the cell. After the value update RadGridView.Validated event is fired.
My question is how cancel de event Validating?
I need Refresh the RadGridView to see the updates?
Before the value is set RadGridView.Validating event is fired. This event could be canceled to prevent updating the value in the cell. After the value update RadGridView.Validated event is fired.
My question is how cancel de event Validating?
I need Refresh the RadGridView to see the updates?
7 Answers, 1 is accepted
0
Accepted

Richard Slade
Top achievements
Rank 2
answered on 01 Dec 2010, 10:18 PM
Hello Fernando,
Hope you're well. I am not quite sure I understand what you wish to do. I think you are trying to update all cells in a column where they are equal to a value to be a new value from a button click. Is that correct?
If so, this small example shows updating a column, and substitutes one value for another.
If this isn't whart you mean, please explain further and I'll be happy to help.
thanks
Richard
Hope you're well. I am not quite sure I understand what you wish to do. I think you are trying to update all cells in a column where they are equal to a value to be a new value from a button click. Is that correct?
If so, this small example shows updating a column, and substitutes one value for another.
Private
Sub
RadButton1_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
RadButton1.Click
Using
Me
.RadGridView1.DeferRefresh()
For
Each
row
As
GridViewRowInfo
In
Me
.RadGridView1.Rows
If
row.Cells(
"ColumnName"
).Value IsNot
Nothing
Then
If
row.Cells(
"ColumnName"
).Value.ToString() =
"SomeValue"
Then
row.Cells(
"ColumnName"
).Value =
"NewValue"
End
If
End
If
Next
End
Using
End
Sub
If this isn't whart you mean, please explain further and I'll be happy to help.
thanks
Richard
0

Fernando
Top achievements
Rank 1
answered on 01 Dec 2010, 10:47 PM
that
code is exactly what I already had, the only thing different is
I do not understand why but it did not work.
Using
Me
.RadGridView1.DeferRefresh()
so I tried it and add it and the value remains unchanged, so add a
message to the cycle that I return the value in cell after being
modified and effectively is the value that was assigned in the table but still with the same valuePrivate
Sub
RadButton1_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
RadButton1.Click
Using
Me
.RadGridView1.DeferRefresh()
For
Each
row
As
GridViewRowInfo
In
Me
.RadGridView1.Rows
If
row.Cells(
"ColumnName"
).Value IsNot
Nothing
Then
If
row.Cells(
"ColumnName"
).Value.ToString() =
"SomeValue"
Then
row.Cells(
"ColumnName"
).Value =
"NewValue"
MsgBox(row.Cells(
"ColumnName"
).Value) 'I add this line and the value chance but in the RadGridView not.
End
If
End
If
Next
End
Using
End
Sub
I do not understand why but it did not work.
0

Richard Slade
Top achievements
Rank 2
answered on 01 Dec 2010, 11:00 PM
Hello Fernando,
Please can you try this simple sample and let me know how it goes for you. It's just a RadGridView and a RadButton on a form
thanks
Richard
Please can you try this simple sample and let me know how it goes for you. It's just a RadGridView and a RadButton on a form
Imports
Telerik.WinControls
Imports
Telerik.WinControls.UI
Public
Class
Form1
Private
Sub
Form1_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
' Make a data source for the grid
Dim
list
As
New
List(Of person)
list.Add(
New
person(
"Richard"
, 1,
"New Milton"
))
list.Add(
New
person(
"Bob"
, 2,
"London"
))
list.Add(
New
person(
"Stewart"
, 3,
"Bournemouth"
))
list.Add(
New
person(
"Chris"
, 4,
"Southampton"
))
list.Add(
New
person(
"Leisl"
, 1,
"Christcurch"
))
list.Add(
New
person(
"Tom"
, 5,
"Weymouth"
))
list.Add(
New
person(
"Oly"
, 6,
"Weymouth"
))
list.Add(
New
person(
"Richard"
, 1,
"New Milton"
))
list.Add(
New
person(
"Bob"
, 2,
"London"
))
list.Add(
New
person(
"Stewart"
, 3,
"Bournemouth"
))
list.Add(
New
person(
"Chris"
, 4,
"Southampton"
))
list.Add(
New
person(
"Leisl"
, 1,
"Christcurch"
))
list.Add(
New
person(
"Tom"
, 5,
"Weymouth"
))
list.Add(
New
person(
"Oly"
, 6,
"Weymouth"
))
list.Add(
New
person(
"Richard"
, 1,
"New Milton"
))
list.Add(
New
person(
"Bob"
, 2,
"London"
))
list.Add(
New
person(
"Stewart"
, 3,
"Bournemouth"
))
list.Add(
New
person(
"Chris"
, 4,
"Southampton"
))
list.Add(
New
person(
"Leisl"
, 1,
"Christcurch"
))
list.Add(
New
person(
"Tom"
, 5,
"Weymouth"
))
list.Add(
New
person(
"Oly"
, 6,
"Weymouth"
))
list.Add(
New
person(
"Richard"
, 1,
"New Milton"
))
list.Add(
New
person(
"Bob"
, 2,
"London"
))
list.Add(
New
person(
"Stewart"
, 3,
"Bournemouth"
))
list.Add(
New
person(
"Chris"
, 4,
"Southampton"
))
list.Add(
New
person(
"Leisl"
, 1,
"Christcurch"
))
list.Add(
New
person(
"Tom"
, 5,
"Weymouth"
))
list.Add(
New
person(
"Oly"
, 6,
"Weymouth"
))
list.Add(
New
person(
"Richard"
, 1,
"New Milton"
))
list.Add(
New
person(
"Bob"
, 2,
"London"
))
list.Add(
New
person(
"Stewart"
, 3,
"Bournemouth"
))
list.Add(
New
person(
"Chris"
, 4,
"Southampton"
))
list.Add(
New
person(
"Leisl"
, 1,
"Christcurch"
))
list.Add(
New
person(
"Tom"
, 5,
"Weymouth"
))
list.Add(
New
person(
"Oly"
, 6,
"Weymouth"
))
' assign the data source of the grid
Me
.RadGridView1.DataSource = list
End
Sub
Private
Sub
RadButton1_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
RadButton1.Click
Using
Me
.RadGridView1.DeferRefresh()
For
Each
row
As
GridViewRowInfo
In
Me
.RadGridView1.Rows
If
row.Cells(
"Name"
).Value IsNot
Nothing
Then
If
row.Cells(
"Name"
).Value.ToString() =
"Richard"
Then
row.Cells(
"Name"
).Value =
"Fernando"
End
If
End
If
Next
End
Using
End
Sub
End
Class
Public
Class
person
Private
m_Customer_Id
As
Integer
Private
m_Name
As
String
Private
m_City
As
String
Public
Sub
New
()
End
Sub
Public
Sub
New
(
ByVal
name
As
String
,
ByVal
id
As
Integer
,
ByVal
city
As
String
)
m_Name = name
m_Customer_Id = id
m_City = city
End
Sub
Public
Property
City()
As
String
Get
Return
m_City
End
Get
Set
(
ByVal
value
As
String
)
m_City = value
End
Set
End
Property
Public
Property
Name()
As
String
Get
Return
m_Name
End
Get
Set
(
ByVal
value
As
String
)
m_Name = value
End
Set
End
Property
Public
Property
Id()
As
Integer
Get
Return
m_Customer_Id
End
Get
Set
(
ByVal
value
As
Integer
)
m_Customer_Id = value
End
Set
End
Property
Public
Property
HasBeard()
As
Integer
Get
Return
m_Customer_Id
End
Get
Set
(
ByVal
value
As
Integer
)
m_Customer_Id = value
End
Set
End
Property
End
Class
thanks
Richard
0

Richard Slade
Top achievements
Rank 2
answered on 01 Dec 2010, 11:05 PM
Note: Some of the properties above were not needed, but I haven't removed them in order to give you this sample quickly.
Thanks
Richard
Thanks
Richard
0

Richard Slade
Top achievements
Rank 2
answered on 01 Dec 2010, 11:09 PM
There. This one is just the same, but with those things that are not needed, removed.
Imports
Telerik.WinControls
Imports
Telerik.WinControls.UI
Public
Class
Form1
Private
Sub
Form1_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
' Make a data source for the grid
Dim
list
As
New
List(Of person)
list.Add(
New
person(
"Richard"
, 1,
"New Milton"
))
list.Add(
New
person(
"Bob"
, 2,
"London"
))
list.Add(
New
person(
"Stewart"
, 3,
"Bournemouth"
))
list.Add(
New
person(
"Chris"
, 4,
"Southampton"
))
list.Add(
New
person(
"Leisl"
, 1,
"Christcurch"
))
list.Add(
New
person(
"Tom"
, 5,
"Weymouth"
))
list.Add(
New
person(
"Oly"
, 6,
"Christcurch"
))
list.Add(
New
person(
"Richard"
, 1,
"New Milton"
))
list.Add(
New
person(
"Bob"
, 2,
"London"
))
list.Add(
New
person(
"Stewart"
, 3,
"Bournemouth"
))
list.Add(
New
person(
"Chris"
, 4,
"Southampton"
))
list.Add(
New
person(
"Leisl"
, 1,
"Christcurch"
))
list.Add(
New
person(
"Tom"
, 5,
"Weymouth"
))
list.Add(
New
person(
"Oly"
, 6,
"Christcurch"
))
list.Add(
New
person(
"Richard"
, 1,
"New Milton"
))
list.Add(
New
person(
"Bob"
, 2,
"London"
))
list.Add(
New
person(
"Stewart"
, 3,
"Bournemouth"
))
list.Add(
New
person(
"Chris"
, 4,
"Southampton"
))
list.Add(
New
person(
"Leisl"
, 1,
"Christcurch"
))
list.Add(
New
person(
"Tom"
, 5,
"Weymouth"
))
list.Add(
New
person(
"Oly"
, 6,
"Christcurch"
))
list.Add(
New
person(
"Richard"
, 1,
"New Milton"
))
list.Add(
New
person(
"Bob"
, 2,
"London"
))
list.Add(
New
person(
"Stewart"
, 3,
"Bournemouth"
))
list.Add(
New
person(
"Chris"
, 4,
"Southampton"
))
list.Add(
New
person(
"Leisl"
, 1,
"Christcurch"
))
list.Add(
New
person(
"Tom"
, 5,
"Weymouth"
))
list.Add(
New
person(
"Oly"
, 6,
"Christcurch"
))
list.Add(
New
person(
"Richard"
, 1,
"New Milton"
))
list.Add(
New
person(
"Bob"
, 2,
"London"
))
list.Add(
New
person(
"Stewart"
, 3,
"Bournemouth"
))
list.Add(
New
person(
"Chris"
, 4,
"Southampton"
))
list.Add(
New
person(
"Leisl"
, 1,
"Christcurch"
))
list.Add(
New
person(
"Tom"
, 5,
"Weymouth"
))
list.Add(
New
person(
"Oly"
, 6,
"Christcurch"
))
' assign the data source of the grid
Me
.RadGridView1.DataSource = list
End
Sub
Private
Sub
RadButton1_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
RadButton1.Click
Using
Me
.RadGridView1.DeferRefresh()
For
Each
row
As
GridViewRowInfo
In
Me
.RadGridView1.Rows
If
row.Cells(
"Name"
).Value IsNot
Nothing
Then
If
row.Cells(
"Name"
).Value.ToString() =
"Richard"
Then
row.Cells(
"Name"
).Value =
"Fernando"
End
If
End
If
Next
End
Using
End
Sub
End
Class
Public
Class
person
Private
m_Customer_Id
As
Integer
Private
m_Name
As
String
Private
m_City
As
String
Public
Sub
New
()
End
Sub
Public
Sub
New
(
ByVal
name
As
String
,
ByVal
id
As
Integer
,
ByVal
city
As
String
)
m_Name = name
m_Customer_Id = id
m_City = city
End
Sub
Public
Property
City()
As
String
Get
Return
m_City
End
Get
Set
(
ByVal
value
As
String
)
m_City = value
End
Set
End
Property
Public
Property
Name()
As
String
Get
Return
m_Name
End
Get
Set
(
ByVal
value
As
String
)
m_Name = value
End
Set
End
Property
End
Class
0

Fernando
Top achievements
Rank 1
answered on 01 Dec 2010, 11:10 PM
i delete the RadGridView and put again in my Form and Work perfect!
thanks the first post is the correct!
thanks the first post is the correct!
0

Richard Slade
Top achievements
Rank 2
answered on 01 Dec 2010, 11:12 PM
Glad this is now working for you.
Richard
Richard