Click here to Skip to main content
15,923,219 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when it Contain String Char & i want it in Decimal eg Datatable Columns Contain Bal and it contain Values (10Dr,20Dr its Record of Column ) and i want only sum of (10+20) then how to get

What I have tried:

I tried this but it contain char DR which give Error object not set
means how to remove char "Dr" from columns value ie 5000Dr i want only 5000 values not 5000Dr..
decimal totalopening = table.AsEnumerable().Sum(row => row.Field<decimal>("Opening"));
gvReport.FooterRow.Cells[1].Text = "Total";
gvReport.FooterRow.Cells[1].HorizontalAlign = HorizontalAlign.Right;
gvReport.FooterRow.Cells[2].Text = totalopening.ToString("N2");
Posted
Updated 11-Apr-16 3:34am

1 solution

Grid View in Used template columns. and add Label then code behind to gridrowDatabown Event in add Calculation this and fined control to assign values.
 
Share this answer
 
Comments
Beginers*Devloper 12-Apr-16 0:20am    
But i want only sum of numbers not char it contain value 100Dr ,200Dr then how to remove this "Dr" and geting sum of this columns...
Beginers*Devloper 12-Apr-16 0:22am    
ie columns Bal contain value(100Dr,200Dr) and i want sum (100+200) ..300
Bal
100Dr
200Dr
300...i except this300 ans
Arvind Zamakia 12-Apr-16 8:13am    
following example help full

string sample ="100Dr";
sample = sample.replace("Dr","");

integer amount1 = convert.int32(sample );

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900