Saturday 9 August 2014

Display Empty Data Text in WebGrid in MVC4


Empty date Text in WebGrid in MVC


Description:-

In this example we explain that how to display Empty Data Text in webgrid in mvc4 with asp.net.we already expl;ain that how to display empty datatext text in grdiview in asp.net but in mvc that is no facility in webgrid to display emptydata text automatically so we have to manually write or define the code for this.

Let have to see a simple tip that shows how to display Empty Data or empty data text in a ASP.NET MVC 4 WebGrid by using WebGrid web helper class.

Here in this post we will check the  model if it  has no data then display a message, similar to the EmptyDataText property of the ASP.NET GridView.


 

To use the WebGrid web helper in mvc application, you have to first create an object reference to the WebGrid class and use the GetHtml() method that renders the grid


 
@{
            Var grid=new WebGrid(Model);
@grid.GetHtml();
}



To Display an Empty Data Text in Webgrid when the Model has no data or no record, just you have to write  following one:

@if(Model.Count>0)
@{
Var grid=new WebGrid(Model);
@grid.GetHtml();
}
Else
<p>No Record Found</p>
}


now completed enjoy the post and run the post if modal has no data then it will display “No Record Found” in webGrid.

https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif



To Show Example of How to Upload File in MVC Application then click here upload Image and bind to Gridview in MVC

To show Example of How to Upload Multiple File in MVC Application then click here upload multiple File in MVC

How to upload File and Fetch file from SqlServer and bind to Gridview fetch file from Sqlserver and bind to Gridview

0 comments:

Post a Comment