我有一个datagridview,我已经以编程方式填充,我想知道如何使其中一列符合指定的格式 – “C2”. 这可以在分配数据源后完成吗? 干杯. var persons = new[] {new {name = "aaa", salary = 40000}, new {na
这可以在分配数据源后完成吗?
干杯.
var persons = new[] {new {name = "aaa", salary = 40000}, new {name = "aaa", salary = 40000}, new {name = "aaa", salary = 40000}, new {name = "aaa", salary = 40000}}; GridView1.DataSource = persons; GridView1.AutoGenerateColumns = false; var NameField = new BoundField(); NameField.HeaderText = "Name"; NameField.DataField = "name"; GridView1.Columns.Add(NameField); var SalaryField = new BoundField(); SalaryField.HeaderText = "Salary"; SalaryField.DataField = "salary"; SalaryField.DataFormatString = "{0:c2}"; SalaryField.HtmlEncode = false; GridView1.Columns.Add(SalaryField); GridView1.DataBind();