Creating dynamic, fancy EmptyDataText for GridView

Gridview has capability to display “default” messages when “No data” exists during binding.

Standard Way in .aspx

<asp:GridView ID=”gvControl” runat=”server” AutoGenerateColumns=”False” GridLines=”None” CellPadding=”0″ CellSpacing=”0″ OnRowDataBound=”gvCategories_RowDataBound” BackColor=”#dddddd” ShowHeader=”false” EmptyDataText=”<BR> No data exists <BR><BR>“>
….
…..
</asp:GridView>

Fancy Way (.vb or .cs)

You can make it fancy & dynamic by doing it in code behind.

nodatagridview.jpg

Create fancy texts using WordArt (MS Word) and copy it to Image Editor (Paint.net, gimp, Paint) and save it as JPG.

[sourcecode language=”vb”] 
gvControl.EmptyDataText = “
gvControl.EmptyDataRowStyle.HorizontalAlign = HorizontalAlign.Center
gvControl.databind[/sourcecode]
Note: When you use emptydatatext in codebehind donot forget to use databind.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: