hai, I`m newbie in Telerik..
I wanna ask something, I have a grid view and when I try to edit the text I have error message like in picture that i have attached..
like on picture number 2 and 3..
I attached setting column like picture no 1..
and here is the code :
How i can resolve it?
Can you give me a link for hint with similar case?
Thanks in advance
Regards
I wanna ask something, I have a grid view and when I try to edit the text I have error message like in picture that i have attached..
like on picture number 2 and 3..
I attached setting column like picture no 1..
and here is the code :
private void grid_CellEndEdit(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
if (grid.CurrentCell.ColumnIndex == 5)
{
grid.CurrentRow.Cells[6].Value = maksharga * (int)grid.CurrentRow.Cells[5].Value;
}
}
How i can resolve it?
Can you give me a link for hint with similar case?
Thanks in advance
Regards
20 Answers, 1 is accepted
0

Richard Slade
Top achievements
Rank 2
answered on 21 Oct 2010, 04:39 PM
Hi,
What column types have you got set up for each column? E.g. GridViewDecimalColumn
It also looks like you are trying to update the value of Cell 6 when Cell 5 updates to perform a calculation. Is that right?
If you can confirm the column types we should be able to help
Thanks
Richard
What column types have you got set up for each column? E.g. GridViewDecimalColumn
It also looks like you are trying to update the value of Cell 6 when Cell 5 updates to perform a calculation. Is that right?
If you can confirm the column types we should be able to help
Thanks
Richard
0

Emanuel Varga
Top achievements
Rank 1
answered on 21 Oct 2010, 05:51 PM
Hello guys,
Mochamad, to fix the problem in your example, just convert the currentRow.Cell.Value to decimal, and that will be fixed.
But i have to warn you, the Cell.Value variable is expected to always match the type of the column, because based on that value, other calculations are performed, if you set a FormatString, like the number of decimals, the date format, which after that are displayed in the cell.Text property of the grid.
That's why you are encountering this error, if you will just add the appropriate casts to the values assigned in the cell.value everything will be ok.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Mochamad, to fix the problem in your example, just convert the currentRow.Cell.Value to decimal, and that will be fixed.
But i have to warn you, the Cell.Value variable is expected to always match the type of the column, because based on that value, other calculations are performed, if you set a FormatString, like the number of decimals, the date format, which after that are displayed in the cell.Text property of the grid.
That's why you are encountering this error, if you will just add the appropriate casts to the values assigned in the cell.value everything will be ok.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0

Mochamad
Top achievements
Rank 1
answered on 22 Oct 2010, 04:16 AM
Hi, thanks for reply
Yes, you right I want to calculate data in grid view but when first I wanna change the text box, I can`t do it and then I change textbox to MaskColumnBox with Numeric as Column Type. I did not get error alert like picture no 2 but the value still not changed..
so If I change value in column "Jml Realisasi" from 0 to 100 I did not get error alert but the value is still is not changed..
How I can fix this?
Regards
Yes, you right I want to calculate data in grid view but when first I wanna change the text box, I can`t do it and then I change textbox to MaskColumnBox with Numeric as Column Type. I did not get error alert like picture no 2 but the value still not changed..
so If I change value in column "Jml Realisasi" from 0 to 100 I did not get error alert but the value is still is not changed..
How I can fix this?
Regards
0

Mochamad
Top achievements
Rank 1
answered on 22 Oct 2010, 04:29 AM
@Varga
Hai, Thanks for reply..
I have changed the code and convert it but i still get same error..
I just attached some property I set before, any some failure I did maybe?
Thanks in advance,
regards
Hai, Thanks for reply..
I have changed the code and convert it but i still get same error..
I just attached some property I set before, any some failure I did maybe?
Thanks in advance,
regards
private
void
grid_CellEndEdit(
object
sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
int
testNumber = 200;
if
(grid.CurrentCell.ColumnIndex == 5)
{
//grid.CurrentRow.Cells[6].Value = Convert.ToDouble(testNumber); //still get error
grid.CurrentRow.Cells[6].Value = Convert.ToDecimal(testNumber);
//grid.CurrentRow.Cells[6].Value = Convert.ToDecimal(maksharga * (int)grid.CurrentRow.Cells[5].Value);
}
}
0

Emanuel Varga
Top achievements
Rank 1
answered on 22 Oct 2010, 07:31 AM
Hello again,
Please try using it like so:
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Please try using it like so:
void
radGridView1_CellEndEdit(
object
sender, GridViewCellEventArgs e)
{
if
(e.Column.Name ==
"Name"
)
{
radGridView1.CurrentCell.Value =
"New Text "
+ e.Value;
}
else
if
(e.Column.Name ==
"Id"
)
{
radGridView1.CurrentCell.Value = 5 + (
decimal
)radGridView1.CurrentCell.Value;
}
}
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0

Mochamad
Top achievements
Rank 1
answered on 22 Oct 2010, 08:34 AM
Hello, Thanks for reply
sorry if I give you more question..
Yeah now I just realize that in my class I have column with property double and then I input to grid.datasource so when I add value I cannot do that because I input double value to DecimalTextBox..
The problem is, If i change property column from double to decimal I worry it will get error in other form because my application was almost finished and it`s too take risks if i do it.
I have made one form with similar case in my project, can you repair this case?
please download this http://www.cloudend.net78.net/download/ExperimentLabs.WinForm.rar
My case is almost similar like the file i have included..
maskbox can`t edit and can not convert to decimal..
Thanks in advance
sorry if I give you more question..
Yeah now I just realize that in my class I have column with property double and then I input to grid.datasource so when I add value I cannot do that because I input double value to DecimalTextBox..
The problem is, If i change property column from double to decimal I worry it will get error in other form because my application was almost finished and it`s too take risks if i do it.
I have made one form with similar case in my project, can you repair this case?
please download this http://www.cloudend.net78.net/download/ExperimentLabs.WinForm.rar
My case is almost similar like the file i have included..
maskbox can`t edit and can not convert to decimal..
Thanks in advance
0

Emanuel Varga
Top achievements
Rank 1
answered on 22 Oct 2010, 08:57 AM
Hello again,
I'm always glad to help.
You can use use double in decimal column without any problems, decimal is just bigger than double.
But you must have at least a double type for the value (not long or int)
You could convert the values directly to double and it will work fine, like so:
If you don't use numbers bigger than double can handle you will be ok :).
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
I'm always glad to help.
You can use use double in decimal column without any problems, decimal is just bigger than double.
But you must have at least a double type for the value (not long or int)
You could convert the values directly to double and it will work fine, like so:
radGridView1.CurrentCell.Value = 5 + Convert.ToDouble(radGridView1.CurrentCell.Value);
If you don't use numbers bigger than double can handle you will be ok :).
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0

Mochamad
Top achievements
Rank 1
answered on 22 Oct 2010, 09:12 AM
Hi again,, thanks for reply..
How about edit text/mask edit which I cannot edit?
Please see the file I have uploaded :)
I'm sorry make you uncomfortable but this simple things make me sooo confused :D
regards and thank you very much :)
How about edit text/mask edit which I cannot edit?
Please see the file I have uploaded :)
I'm sorry make you uncomfortable but this simple things make me sooo confused :D
regards and thank you very much :)
0

Emanuel Varga
Top achievements
Rank 1
answered on 22 Oct 2010, 09:16 AM
Hello again,
Which file? I couldn't find a mask in any of the files you have uploaded, can you please point me in the right direction?
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Which file? I couldn't find a mask in any of the files you have uploaded, can you please point me in the right direction?
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0
0

Emanuel Varga
Top achievements
Rank 1
answered on 22 Oct 2010, 03:08 PM
Hello again,
Sorry for the delay :(,
You can set a mask to GridViewMaskBoxColumn using its Mask and MaskType properties. You can find further information about the possible values for these properties in RadMaskEditBox documentation section.
You can access there properties, either using the PropertyBuilder -> Select Column -> Advanced.
Or in code, register to the DataBindingComplete event and access the column there, like so:
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Sorry for the delay :(,
You can set a mask to GridViewMaskBoxColumn using its Mask and MaskType properties. You can find further information about the possible values for these properties in RadMaskEditBox documentation section.
You can access there properties, either using the PropertyBuilder -> Select Column -> Advanced.
Or in code, register to the DataBindingComplete event and access the column there, like so:
void
radGridView1_DataBindingComplete(
object
sender, GridViewBindingCompleteEventArgs e)
{
var maskedColumn = radGridView1.Columns[
"NumberCol"
]
as
GridViewMaskBoxColumn;
maskedColumn.MaskType = MaskType.Numeric;
maskedColumn.Mask =
"#"
;
}
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0

Mochamad
Top achievements
Rank 1
answered on 24 Oct 2010, 02:33 PM
hai, sorry for late reply..
Do I and you have miss communication because when i was tried it, still not get working..
The process what i want is when I edit Num Col, it will be done..but there is no happen when I edit mask box..
for see the process please see file I have uploaded..
file 1 -> 2 -> 3
Or if you not mind, can you send me my file that you was edit to my email mochamad.fazar@gmail.com
thanks and regards
Do I and you have miss communication because when i was tried it, still not get working..
The process what i want is when I edit Num Col, it will be done..but there is no happen when I edit mask box..
for see the process please see file I have uploaded..
file 1 -> 2 -> 3
Or if you not mind, can you send me my file that you was edit to my email mochamad.fazar@gmail.com
thanks and regards
0
0

Emanuel Varga
Top achievements
Rank 1
answered on 24 Oct 2010, 04:22 PM
Hello again,
I think i don't understand exactly what you want to achieve, I've posted a link to the documentation article in one of my previous posts where you can find examples of masks to use in the GridViewMaskBoxColumn, and in the DataBindingComplete you can set the mask you want on that column, can you please tell me what is not working?
I hope you are not talking about formatting the text in the column, there is a different property for that called FormatString.
Please clarify this, if you can, please draw on the images what do you expect to see
Best Regards,
Emanuel Varga
I think i don't understand exactly what you want to achieve, I've posted a link to the documentation article in one of my previous posts where you can find examples of masks to use in the GridViewMaskBoxColumn, and in the DataBindingComplete you can set the mask you want on that column, can you please tell me what is not working?
I hope you are not talking about formatting the text in the column, there is a different property for that called FormatString.
Please clarify this, if you can, please draw on the images what do you expect to see
Best Regards,
Emanuel Varga
0

Mochamad
Top achievements
Rank 1
answered on 25 Oct 2010, 09:51 AM
Hai,
What I want to achieve is so simple, I just want to change text in textbox value and the textbox have type int in behind code like in picture.
Can you give me back the program which I gave to you before?
I used version Telerik.grid view 2010.2.10.713
One point again, I was saw that my program running well if I used telerik version 2009 :(
regards
What I want to achieve is so simple, I just want to change text in textbox value and the textbox have type int in behind code like in picture.
Can you give me back the program which I gave to you before?
I used version Telerik.grid view 2010.2.10.713
One point again, I was saw that my program running well if I used telerik version 2009 :(
regards
0

Emanuel Varga
Top achievements
Rank 1
answered on 25 Oct 2010, 02:03 PM
Hello again,
Sorry for the delay, but here is all the code i have changed:
Please let me know if this has solved your problem.
Best Regards,
Emanuel Varga
Sorry for the delay, but here is all the code i have changed:
using
System;
using
System.Collections.Generic;
using
System.Windows.Forms;
using
Telerik.WinControls.UI;
namespace
WinForm
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
List<SetData> sd =
new
List<SetData>();
SetData d =
new
SetData
{
Name =
"test 1"
,
NumberCol = 100,
DecimalCol = Convert.ToDouble(200),
NumText = 99
};
sd.Add(d);
d =
new
SetData
{
Name =
"test 2"
,
NumberCol = 200,
DecimalCol = Convert.ToDouble(300.00),
NumText = 98
};
sd.Add(d);
radGridView1.DataBindingComplete +=
new
GridViewBindingCompleteEventHandler(radGridView1_DataBindingComplete);
radGridView1.CellEndEdit +=
new
GridViewCellEventHandler(radGridView1_CellEndEdit);
radGridView1.DataSource = sd;
}
private
void
radGridView1_CellEndEdit(
object
sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
if
(e.ColumnIndex == 1)
{
radGridView1.CurrentRow.Cells[2].Value = 6 * Convert.ToDouble(e.Value);
}
}
void
radGridView1_DataBindingComplete(
object
sender, GridViewBindingCompleteEventArgs e)
{
var maskedColumn = radGridView1.Columns[
"NumberCol"
]
as
GridViewMaskBoxColumn;
maskedColumn.MaskType = MaskType.Numeric;
maskedColumn.Mask =
"N0"
;
var decimalColumn = radGridView1.Columns[
"DecimalCol"
]
as
GridViewDecimalColumn;
decimalColumn.ThousandsSeparator =
true
;
decimalColumn.DataType =
typeof
(Double);
}
}
public
class
SetData
{
public
string
Name
{
get
;
set
;
}
public
int
NumberCol
{
get
;
set
;
}
public
double
DecimalCol
{
get
;
set
;
}
public
int
NumText
{
get
;
set
;
}
}
}
Please let me know if this has solved your problem.
Best Regards,
Emanuel Varga
0

Mochamad
Top achievements
Rank 1
answered on 25 Oct 2010, 05:29 PM
Hi again,,
Many Thanks for wrote back the code..
Decimal value was worked well..but "NumberCol"
Many Thanks for wrote back the code..
Decimal value was worked well..but "NumberCol"
still get same error..
Object of type "System.String" cannot be converted to type System.Int32..
Do you forget or miss something?
regards
0

Emanuel Varga
Top achievements
Rank 1
answered on 25 Oct 2010, 09:50 PM
Hello again,
I cannot understand how you can enter strings inside the NumberCol, I've set a mask for numeric with N0, which should allow you to enter only numbers in the cells for the NumberCol column.
Please update to the latest version and let me know if this solves your problem, or, if you made any changes to the code I've posted before please let me know what those changes are.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
I cannot understand how you can enter strings inside the NumberCol, I've set a mask for numeric with N0, which should allow you to enter only numbers in the cells for the NumberCol column.
Please update to the latest version and let me know if this solves your problem, or, if you made any changes to the code I've posted before please let me know what those changes are.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0
Accepted
Hi Mochamad,
It will be better to handle CellValueChanged event in this case. This event fires when a cell changes its value. You can find more information in this help article.
As an alternative solution, you can use column expressions. Please consider the GridView >> Manipulate Data >> Expressions example in our Demo application.
I hope this helps.
Greetings,
Jack
the Telerik team
It will be better to handle CellValueChanged event in this case. This event fires when a cell changes its value. You can find more information in this help article.
As an alternative solution, you can use column expressions. Please consider the GridView >> Manipulate Data >> Expressions example in our Demo application.
I hope this helps.
Greetings,
Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Mochamad
Top achievements
Rank 1
answered on 27 Oct 2010, 03:47 AM
Ok, I will try it..
Many Thanks for Jack and Vargas :)
I`m so appreciate it..
Regards
Many Thanks for Jack and Vargas :)
I`m so appreciate it..
Regards