ASP.NET MVC 3: Display Empty Data Text in WebGrid

Let us see a simple tip that shows how to display Empty Data in a ASP.NET MVC 3 WebGrid. If you are new to the WebGrid Web helper control, I strongly recommend you to read an article by Malcolm on WebGrid WebHelper in ASP.NET MVC 3

In this post, we will detect if the model has no data and display a message, similar to the EmptyDataText property of the ASP.NET GridView.

To use the WebGrid web helper, we will first create an object reference to the WebGrid class and use the GetHtml() method that renders the grid


To add an Empty Data Text when the Model has no data, just replace the above code with the following one:


That’s it! The next time you run your application and if the model has no data in it, the text ‘No Data Found’ will be displayed. Similarly you can display an image or any other HTML text to convey the message.

Will you give this article a +1 ? Thanks in advance

About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal


0 Responses to "ASP.NET MVC 3: Display Empty Data Text in WebGrid"

Copyright © 2009-2014 All Rights Reserved for by Suprotim Agarwal | Terms and Conditions