5
Answers

How to replace empty column as "ND" using ASP.NET C#?

Raja

Raja

8y
339
1
I want to set value for particular empty column in data set data table as "ND" in data set.
How to do it?
 
 What I have tried:
 
if (ds.Tables[s].Rows[i][Columncountvalue + 19].ToString().Trim() == "")
 {
ds.Tables[s].Rows[i][Columncountvalue + 19].ToString().Trim().Replace("", "ND");
 }
 the above code is i tried to fill the empty column as "ND" in dataset data table but below error is occurs

string cannot be of zero length. parameter name oldvalue
Answers (5)
1
Amit Gupta

Amit Gupta

NA 16.5k 25.6k 8y
If the database column is type of string then it recommend you to change the datatype to decimal, it will help you in future and many more queries.
 
However, if currency contains ,(comma) and you need to validate that by using the replace method
 
String cur ="12,000";
var value = Convert.ToDecimal (curr.Replace (",", "");
 
// now value contains only numbers without and seperator