C# 更改加载页面上的GridView单元格字符串
我有一个GridView,它有一个名为C# 更改加载页面上的GridView单元格字符串,c#,asp.net,gridview,C#,Asp.net,Gridview,我有一个GridView,它有一个名为Active的列,显示1(对于Active)或-1(对于inactive) 但是,由于这是在前端UI中实现的,我不希望用户看到他们认为无用的整数,但是活动的或非活动的将显示在页面加载的网格视图中 代码看起来像- protected void Page_Load(object sender, EventArgs e) { //code here to modify the column 'Active' in the GridView
Active
的列,显示1
(对于Active)或-1
(对于inactive)
但是,由于这是在前端UI中实现的,我不希望用户看到他们认为无用的整数,但是活动的
或非活动的
将显示在页面加载的网格视图中
代码看起来像-
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更加美观,如何才能做到这一点?尝试Gridview事件