如何解决GridView绑定列为0无法显示的问题?

来源:百度知道 编辑:UC知道 时间:2024/09/24 16:52:57
数据源中的数据列为零时在GridView中无法显示0,而是空值 。请问有什么方法可以让0值列的项显示出来0来??


protected void GridView_RowDataBound事件中加入
if (e.Row.RowType != DataControlRowType.Header && e.Row.RowType != DataControlRowType.Footer)
{
if (e.Row.RowIndex >= 0)
{
对象 a = e.Row.DataItem as 对象;
if(a.列=="")
{
e.Row.Cells[index].Text = "0";
}
}
}