【发布时间】:2013-01-17 17:52:04
【问题描述】:
我有一个 GridView,它有一个名为 Active 的列,其中显示 1(用于活动)或 -1 用于非活动。
但是,由于这是在前端 UI 中实现的,我不希望用户看到他们认为无用的整数,而是在 Page_Load 的 GridView 中显示 Active 或 Not active .
代码看起来像 -
protected void Page_Load(object sender, EventArgs e)
{
//code here to modify the column 'Active' in the GridView
//GridView ID="GV1"
if (row.Cells[1].Text == "1")
{
row.Cells[1].Text = "Active";
}
if (row.Cells[1].Text == "-1")
{
row.Cells[1].Text = "Not Active";
}
}
而GridView中的列是-
<asp:BoundField HeaderText="Active" DataField="Active" SortExpression="Active"></asp:BoundField>
由于我不想编辑数据库以使 UI 更美观,我该怎么做?
【问题讨论】: