Published articles on other web sites*

Published articles on other web sites*

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

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

mvcwebgrid

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

mvcemptywebgrid

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.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...