How do you call a codebehind/class method from a gridview in an aspx page? Also, I need to pass the value of databound column to that method. Is this possible?
Something like this:
<asp:BoundField DataField="Precision" />
<asp:BoundField DataField="MyNumber" DataFormatString="FormatHelper.Format(MyNumber, Precision)" />
Edit: I tested this to work.
This works because the Eval method takes the
DataFormatStringas an optional second parameter. note: Make sure you replace the casts with the appropriate types for the method signature.An easier way might be to bind to a linq-to-objects projection instead.