बस पूर्णता के लिए, क्योंकि मैं एक समाधान खोज की है और यहाँ पहली बार आया ...
आप string.Format()
का उपयोग करके और अधिक लचीलापन मिल गया है
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<%# string.Format("{0} {1}", Eval("field1") ,Eval("field2"))%>
</ItemTemplate>
</asp:TemplateField>
यहां आप दा प्रारूपित करने के लिए string.Format()
की शक्ति का भी उपयोग कर सकते हैं ते और संख्या प्रकार यहाँ descriped के रूप में: https://docs.microsoft.com/en-us/dotnet/standard/base-types/formatting-types
नमूना:
<%# String.Format("{0:MM/dd/yyyy} - {1:N2}", Eval("field1"), Eval("field2")) %>
एक अन्य विकल्प कोड में एक कस्टम विधि में पीछे के बजाय String.Format यह करने के लिए है
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Label runat="server" Text='<%#GetStatus(Eval("Status1"),Eval("Status2")) %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
कोडबेइंड:
public string GetStatus(object Status1, object Status2)
{
return (string)Status1 + " " + (string)Status2;
}
उचित पूंजीकरण और वर्तनी हमेशा एक प्लस =) – jadarnel27