开发者

asp:BoundField Yes/ no instead true false

Hi i have a datagrid with

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

PrenotazioneEffettua开发者_如何转开发ta is a boolean field.

In the grid there is true/false value

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

thanks


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";
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜