0

こんにちは、私はデータグリッドを持っています

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

PrenotazioneEffettuata はブール フィールドです。

グリッドには真/偽の値があります

true/false の代わりに yes/no を出力できますか?

ありがとう

4

1 に答える 1

0

テンプレートフィールドにして、行データバインドイベントの値を変更できます。お気に入り...

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

コードビハインド

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";
        }
    }
}
于 2009-12-16T11:16:39.650 に答える