Can I convert a boolean to Yes/No in a ASP.NET GridView

前端 未结 9 1234
孤街浪徒
孤街浪徒 2020-12-22 17:17

I have a ASP.NET GridView with a column mapped to a boolean. I want do display \"Yes\"/\"No\" instead of \"True\"/\"False\". Well actually I want \"Ja\"/\"Nej\"

9条回答
  •  时光说笑
    2020-12-22 17:27

    This works:

    Protected Sub grid_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grid.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            If e.Row.Cells(3).Text = "True" Then
                e.Row.Cells(3).Text = "Si"
            Else
                e.Row.Cells(3).Text = "No"
            End If
        End If
    End Sub
    

    Where cells(3) is the column of the column that has the boolean field.

提交回复
热议问题