【问题标题】:Change GridView cells strings on Page_Load在 Page_Load 上更改 GridView 单元格字符串
【发布时间】:2013-01-17 17:52:04
【问题描述】:

我有一个 GridView,它有一个名为 Active 的列,其中显示 1(用于活动)或 -1 用于非活动。

但是,由于这是在前端 UI 中实现的,我不希望用户看到他们认为无用的整数,而是在 Page_Load 的 GridView 中显示 ActiveNot 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 更美观,我该怎么做?

【问题讨论】:

    标签: c# asp.net gridview


    【解决方案1】:

    试试OnRowDataBound Gridview 事件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多