i am using asp.net MVC2 and i am getting an error on the follwoing line of code
<% double RunningTotal = 0; %>
<%foreach (var item in Model)
{%>
<%var allowedHours = item.tblPerson.tblPersonAllowedHours.Where(x=>x.Semester == item.Semester).Sum(x=>x.AllowedHoursPerWeek); %>
<tr>
<td><%: item.Semester %></td>
<td><%: allowedHours.ToString() %></td>
<td><%: item.tblPerson.tblCourseWantedHours.Where(x => x.Semester == item.Semester).Sum(x => x.WantedHoursPerWeek+x.UL+x.UT) %></td>
<td><%: item.tblPerson.tblCourseWantedHours.Where(x => x.Semester == item.Semester).Sum(x => x.WantedHoursPerWeek+x.UL+x.UT) - allowedHours %></td>
<%: RunningTotal += (item.tblPerson.tblCourseWantedHours.Where(x => x.Semester == item.Semester).Sum(x => x.WantedHoursPerWeek + x.UL + x.UT) - allowedHours) %>
<td></td>
the error i am getting is on this line
<%: RunningTotal += (item.tblPerson.tblCourseWantedHours.Where(x => x.Semester == item.Semester).Sum(x => x.WantedHoursPerWeek + x.UL + x.UT) - allowedHours) %>
error description is
CS0266: Cannot implicitly convert type 'double?' to 'double'. An explicit conversion exists (are you missing a cast?)
any idea what i am missing here?
It looks like one of the things you are trying to add might be a Nullable<Double>
to go from double? to double you need to do
double? nullableDouble = 3.0;
if (nullableDouble.HasValue)
double notNullableDouble = nullableDouble.Value;
More info on Nullables: http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With