When we are binding data to GridView we might need to format the data. Below code shows how can we use string.Format with Eval.
string.Format with Eval:
<asp:TemplateField HeaderText="Full Name">
<ItemTemplate>
<%# string.Format("{0} {1}", Eval("FirstName"),Eval("LastName")) %>
</ItemTemplate>
</asp:TemplateField>
Direct format for Control:
<asp:TemplateField HeaderText="Full Name">
<ItemTemplate>
<asp:Label ID="lblFullName" runat="server" Text='<%# Eval("FirstName") + " " + Eval("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
DataBinder.Eval with Format:
DataBinder.Eval method itself has string format as parameter. Using this we can format with single value Eval.
'<%# DataBinder.Eval(Container.DataItem, "createdatetime", "{0:MM/dd/yyyy}") %>'