I have an eval in an aspx page that has an eval in the template of a gridview. My problem is that that eval calls a method with parameters that are object. Can I change the method to accept the proper parameters and use cast with the eval stament.
I need something like this:
<%# MyClas.MyMethod((string)Eval("Param1"),(int)Eval("Param2"), (string)Eval("Param3"))%>
You could create your signature to contain the right types or type object. This is entirely dependent on the data and your preference. If any of your parameters return NULL, there may be an exception with the casting of your evaluated data item. I personally prefer the first option, but then I always ensure that there will not be a null in the result set.
Option 1:
Code:
or Option 2:
Code:
I hope this helps.