Answer: Sometimes, you need to bind data using ternary functions from code file. With VB, you can achieve this thing using IIF function.
For an example, here in code below at the time of databinding I need to check value of “testString”. If the value is null/empty string it shows “NA” else the value.
<%#IIf(String.IsNullOrEmpty(DataBinder.Eval(Container.DataItem, "testString")), "NA", DataBinder.Eval(Container.DataItem, " testString "))%>
You can achieve the same result from code behind by placing appropriate code in itemdatabound method.(if applicable)
Asked In: Many Interviews |
Alert Moderator