문제

I have a radGridView bound to a SQL table. One of the column shall contain a calculated result.

this.radGridView1.Columns[4].Expression = "Due - Paid";

All 3 fields involved are nvarchar type. I get this error and I do not understand how to fix it: enter image description here

Any hint on what could be possibly wrong?

도움이 되었습니까?

해결책

I was able to replicate this. It's due to the column types you're trying to subtract.

I created a RadGridView and populated it using this code, which compiles fine but displays the exact error you received when it tries to display the grid at runtime.

radGridView1.Columns.Add(new GridViewTextBoxColumn("age"));
radGridView1.Columns.Add(new GridViewTextBoxColumn("iq"));
radGridView1.Columns.Add(new GridViewDecimalColumn("total"));

radGridView1.Rows.Add("5", "5");

radGridView1.Columns["total"].Expression = "age - iq";

Changed the column types accordingly and it worked fine:

radGridView1.Columns.Add(new GridViewDecimalColumn("age"));
radGridView1.Columns.Add(new GridViewDecimalColumn("iq"));

You just need to make sure the column data are numbers, not strings.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top