views:

89

answers:

1

Hi i have a datagrid with

<asp:BoundField DataField="PrenotazioneEffettuata" HeaderText="Pren. Effettuate"
                        SortExpression="PrenotazioneEffettuata"  />

PrenotazioneEffettuata is a boolean field.

In the grid there is true/false value

is possible print yes/no instead of true/false?

thanks

A: 

you can make it to template field and change value in row databound event. like...

  <ItemTemplate>
        <asp:Label runat="server" ID="lbl"> </asp:Label>
  </ItemTemplate>

Code behind

protected void yourGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        DataRow dr = ((DataRowView)e.Row.DataItem).Row;
        if(Convert.ToBoolean( dr["PrenotazioneEffettuata"]))
        {
            ((Label)e.Row.FindControl("lbl")).Text = "Yes";
        }
        else
        {
            ((Label)e.Row.FindControl("lbl")).Text = "No";
        }
    }
}
Muhammad Akhtar