Hi all;
How to make inline eval if control ?
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<%# if(Eval("Bla Bla Bla").ToString().Length <= 15){Eval("Bla Bla Bla")}else{Eval("Bla Bla Bla").ToString().Substring(0,15)}%>
</ItemTemplate>
</asp:TemplateField>
ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites. It allows you to use a full featured programming language such as C# or VB.NET to build web applications easily.
ASP.NET is a web application development framework used to develop web applications using different back-end programming languages like C# where C# is used as an object-oriented programming language to develop web applications along with ASP.NET.
. NET Framework is an object oriented programming framework meant to be used with languages that it provides bindings for. Since C is not an object oriented language it wouldn't make sense to use it with the framework.
C# is a programming language, . NET is a blanket term that tends to cover both the . NET Framework (an application framework library) and the Common Language Runtime which is the runtime in which . NET assemblies are run.
Use the tertiary expression '?':
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<%# Eval("Bla Bla Bla").ToString().Length <= 15 ? Eval("Bla Bla Bla") : Eval("Bla Bla Bla").ToString().Substring(0,15) %>
</ItemTemplate>
</asp:TemplateField>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With