No Acessible 'ToString"

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I am getting the following error and I don't understand what it really
means.


Compiler Error Message: BC30518: Overload resolution failed because no
accessible 'ToString' can be called with these arguments:

Source Error:


Line 51: <ItemTemplate>
Line 52: <tr>
Line 53: <%# WeekHeader(Container.DataItem("StartDate"),
lastdate) %>
Line 54: <td><%# DataBinder.Eval(Container.DataItem,
"StartDate", "{0:d}") %> </td>
Line 55:

The Subroutine code is as follows:

Sub WeekHeader( startdate As Date, lastd As Date)
If startdate > lastd Then
Response.Write("<tr><td>" & startdate.Tostring("d") & "</td></tr>")
lastd = startdate
End If
End Sub
 
first off, I'd use DateTime.. this would definitely work
startDate.ToString("d") but I got the code in the sub to work.

However, you can use Date.ToString("d") without incident, so I'm wondering
if it isn't soemthing else. The first thing I noticed is that the IDE isn't
automatically changing the case of the S in ToString which would be a
problem in C# but since this is vb.net and since the exception message
indicates that it does know this is the ToString method, that's not it.
There are four overloads for date, ToString(), ToString(string,
IFormatProvider), ToString(string), ToString(IFormatProvider) so passing in
a String is definitely an acceptable overload. Wondering if something else
isn't doing this?

The other piece is referencing StartDate which seems to be of different
case, but then again, it's VB.NET so this isn't the issue.



--
W.G. Ryan MVP Windows - Embedded

www.devbuzz.com
www.knowdotnet.com
http://www.msmvps.com/williamryan/
 
Thanks for the feedback William. I had tried using DateTime but noticed that
the system (WebMatrix) showed Date as valid but not DateTime? I thought I
did try that anyway with no change in the error but I'll go back and try
again.

In Googling to other sites I am seeing that it is better to simply call
functions or subs from the in-line code rather than executing the logic
in-line. I am going to revise my code to try that approach!

Wayne
 
Back
Top