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.
Tweet
No comments:
Post a Comment