2009-12-16 31 views
0

嗨,我有ASP:BoundField的是/否,而不是真正的假

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

PrenotazioneEffettuata是一個布爾領域的數據網格。

在網格中有真/假值

可以打印的是/否,而不是真/假?

謝謝

回答

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"; 
     } 
    } 
} 
相關問題