【问题标题】:asp:BoundField Yes/ no instead true falseasp:BoundField 是/否 而是 true false
【发布时间】:2009-12-16 19:18:21
【问题描述】:
您好,我有一个带有
的数据网格
<asp:BoundField DataField="PrenotazioneEffettuata" HeaderText="Pren. Effettuate"
SortExpression="PrenotazioneEffettuata" />
PrenotazioneEffettuata 是一个布尔字段。
在网格中有真/假值
是否可以打印是/否而不是真/假?
谢谢
【问题讨论】:
标签:
asp.net
gridview
boundfield
【解决方案1】:
您可以使其成为模板字段并更改行数据绑定事件中的值。喜欢...
<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";
}
}
}