Although DataBinder.Eval() function is very easy to use, it imposes performance penality due to late binding. This can be avoided using explicit casting. Following code snippet shows both the approaches:
Using DataBinder:
<%# DataBinder.Eval(Container.DataItem, "TotalAmount", "{0:n}" %>
Using Explicit Casting:
<%# String.Format("{0:n}", ( (DataRow)(Container.DataItem))["TotalAmount"]) %>
No comments:
Post a Comment