我试图总结一个具有值的列,但它们在值前面有"$"字符.
如何删除值前面的$以将其转换为小数,这样我就不会收到任何错误?
这是我用来执行此操作的代码:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.DataItem != null)
{
// Set the capacity label text
sum += Decimal.Parse(e.Row.Cells[4].Text);
Label5.Text = "Total:"+" $" + sum.ToString();
}
}
Run Code Online (Sandbox Code Playgroud)