开发者

asp:BoundField Yes/ no instead true false

开发者 https://www.devze.com 2022-12-14 07:43 出处:网络
Hi i have a datagrid with <asp:BoundField DataField=\"PrenotazioneEffettuata\" HeaderText=\"Pren. Effettuate\"

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

精彩评论

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