I will suggest to do it in SQL
only:
using ISNULL(expression, value_if_expression_is_null)
or
COALESCE(expression, expression2, expression3)
example :
SELECT
Name, DOB,
(CASE WHEN Address1 IS NULL THEN 'NA' ELSE Address1 END) AS Address1,
(CASE WHEN Address2 IS NULL THEN 'NA' ELSE Address2 END) AS Address2,
...
FROM Users
or
SELECT
Name, DOB, Address1,
coalesce(Address2,'NA'), coalesce(City,'NA'),
coalesce(State,'NA'), coalesce(Zip,'NA')
FROM Users
Well you can try to do something like:
<%#(string.IsNullOrEmpty(Eval("TypeOfPainting").ToString()) ? "NA" : Eval("TypeOfPainting"))%>
Your control is runat="server"
Why dont you control the value in codebehind?
If (string.IsNullOrEmpty(TypeofPaintingValue))
{
TypeofPainting.Text="NA";
}
by creating a public method
You can complete this task very easily like
public string testbind(object myvalue)
{
if (myvalue == null)
{
return "NA value";
}
return myValue.ToString();
}
Label Code:
<asp:Label ID="TypeOfPaintingLabel" Text='<%# testbind(Eval("TypeOfPainting")) %>' runat="server"></asp:Label>
Or you may use
<%#(String.IsNullOrEmpty(Eval("TypeOfPainting").ToString()) ? "NA" : Eval("TypeOfPainting"))%>
You have to follow this type of scenarion.
Hope it works.
you can set this things from database side also
ISNULL(TypeOfPainting,'NA') AS TypeOfPainting