I am calling a function using vb and want to convert it to c#.  When moving 
from vb 1.1 to vb 2.0, I can use the following: text='<%# 
AddBlankRowMenu(Eval("strMenuType")) %>'  to call the function.  I no longer 
need to use "DataBinder.Eval(Container,"DataItem." in front of the DataItem. 
However, when I tried to use the new syntax in c#, I got an error.  However, 
the older syntax works.
Am I missing something, or does c# require the longer syntax as shown below?
-- 
Thanks, sck10
vb: asp.net 1.1
<asp:Literal id="ltrNewLine" text='<%# 
AddBlankRowMenu(DataBinder.Eval(Container,"DataItem.strMenuType")) %>' 
runat="server" />
vb: asp.net 2.0
<asp:Literal id="ltrNewLine" text='<%# AddBlankRowMenu(Eval("strMenuType")) 
%>' runat="server" />
c#: asp.net 2.0
<asp:Literal id="ltrNewLine" text='<%# 
AddBlankRowMenu(DataBinder.Eval(Container,"DataItem.strMenuType")) %>' 
runat="server" /> 
As for the databinding expression in ASPX template, they're dynamically 
compiled at runtime, and the error you encountered is likely due to the 
different compile option between VB.NET and C#.   For VB.NET, it is using 
latebinding that means wo do not need to convert the object to the actual 
expected type and the runtime will use latebinding to evaluate and 
determine the object type.  However, C# will always enforce type checking 
at compile time, if there is type mismatch in code, it will report error.
Thus, for your case,  "DataBinder.Eval" or "Eval"(asp.net 2.0 specific) 
will return an "Object" , however, our custom function( such as the 
"AddBlankRowMenu" ) will expect a non-Object type parameter, this will 
cause the C# compilter report error.  What's the object type expected by 
the "AddBlankRowMenu" function in your case?  You can consider:
1. Explicitly case the object returned from the "Eval"  to the expected 
type of the "AddBlankRowMenu" function before pass it to the function.
2. Change the "AddBlankRowMenu"'s input parameter to "Object" type , and 
perform the type convertion inside the function.
Please feel free to let me know if there works for you or if you meet any 
further problem on this.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial 
response from the community or a Microsoft Support Engineer within 1 
business day is 
acceptable. Please note that each follow up response may take approximately 
2 business days 
as the support professional working with you may need further investigation 
to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require 
urgent, real-time or phone-based interactions or complex project analysis 
and dump analysis 
issues. Issues of this nature are best handled working with a dedicated 
Microsoft Support 
Engineer by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.