日期:2014-05-19  浏览次数:20894 次

IsDBNull的问题
if   (Information.IsDBNull(new   OverTimeData().ActualHours(guidHeadId).Tables[0].Rows[0][ "ActualWorkingHours "]))//片断是否为0(VB)
                        {
                                throw   new   Exception( "请先填写实际加班时间! ");

                        }
怎么把上面的该成对GridView的所有行进行检验?而不是单单第一行。

------解决方案--------------------
在GridView_RowDataBound()中写那些判断的代码

if ((ListItemType)e.Row.RowType == ListItemType.AlternatingItem || (ListItemType)e.Row.RowType == ListItemType.Item)
{
if (Information.IsDBNull(new OverTimeData().ActualHours(guidHeadId).Tables[0].Rows[0][ "ActualWorkingHours "]))//片断是否为0(VB)
{
throw new Exception( "请先填写实际加班时间! ");

}

}