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

Issue with Datacolumn

4 Answers 69 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nicky
Top achievements
Rank 1
Nicky asked on 08 Nov 2007, 02:07 AM
Hi Telerik,

I am using radGridview facing problem for assing datacolumn value to local variable for some calculation part and then adding it to datacolumn expression here is the example.

DataColumn colAccure = new DataColumn("DCAccure");

colAccure.DataType = typeof(System.Decimal);

--  int a = DCAccure.Tostring();
    a = SQRT(a);// some calculation part like this
--
colAccure.Expression =
"( FlatPrice + a)";

dt.Columns.Add(colAccure);


In the above examle i am getting value of DCAccure and need to assign it to local variable a , Not able to assign it and after having certain calculation with a need to add it to column express that is also giving error.

Please provide Solution.

Thanks
Nicky

4 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 08 Nov 2007, 04:12 PM
Hello Nicky,

All the code you have sent is correct, except for this line: 

colAccure.Expression = "( FlatPrice + a)";  
 

When seting up expressions, all variables should be parsed as a string. Here is an example with you code snippet:


DataColumn colAccure = new DataColumn("DCAccure");     
colAccure.DataType = typeof(System.Decimal);     
    
CultureInfo ci = Thread.CurrentThread.CurrentCulture; //change to current culture for expression to parse double in right way     
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");     
    
double a = 5;     
a = Math.Sqrt(a);// some calculation part like this      
colAccure.Expression = string.Format("(FlatPrice + {0})", a);     
    
this.nwindDataSet.Orders.Columns.Add(colAccure);     
    
Thread.CurrentThread.CurrentCulture = ci;    //return previous culture    
 


Let us know if this helps.


All the best,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Nicky
Top achievements
Rank 1
answered on 09 Nov 2007, 12:58 AM
Hi julian,

Thanks for reply.
first part of my  question is how to add data column to string of double
you answer the second part of question.

Like

DataColumn colAccure = new DataColumn("DCAccure");

colAccure.DataType = typeof(System.Decimal);

--  int a = DCAccure.Tostring();


Thanks
Nicky

0
Nicky
Top achievements
Rank 1
answered on 09 Nov 2007, 12:58 AM
Hi julian,

Thanks for reply.
first part of my  question is how to add data column to string of double
you answer the second part of question.

Like

DataColumn colAccure = new DataColumn("DCAccure");

colAccure.DataType = typeof(System.Decimal);

--  int a = DCAccure.Tostring();


Thanks
Nicky

0
Julian Benkov
Telerik team
answered on 12 Nov 2007, 08:58 AM
Hi Nicky,

Thank you for writing.

In order to assign DCAccure value to local member you must use a Converter:

int a = Convert.ToInt32(DCAccure); 

If you have any additional questions, please contact us.

Kind regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Nicky
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Nicky
Top achievements
Rank 1
Share this question
or