Displaying Custom Messages / Images with NULL Value in ASP.NET GridView

When we  bind some data source with GridView which contains some fields with NULL value,  ASP.NET renders them as Blank.

image

Sometimes developers use GridView_RowDataBound() to override the NULL value with proper message. But Instead of overriding the value, we can use NullDisplayText to display proper message when the value for that particular field is NULL .

image

Once we mentioned NullDisplayText=”No Data” for every field for that Bound Filed which having NULL value will be replace by “No Data”
image

Even we can customize the Text with HTML Formatting as shown in below.

image

image

One more interesting point is, we  can also display Images for NULL Value

image

image

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

2 Comments to “Displaying Custom Messages / Images with NULL Value in ASP.NET GridView”

Comments are closed.