Script(s)

what I learn is what u c

Posts Tagged ‘gridview

Creating dynamic, fancy EmptyDataText for GridView

with 2 comments

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.

 
gvControl.EmptyDataText = "<img src='~/images/NoData.jpg' border='0'>"
gvControl.EmptyDataRowStyle.HorizontalAlign = HorizontalAlign.Center
gvControl.databind

Note: When you use emptydatatext in codebehind donot forget to use databind.

Written by gchandra

October 24, 2007 at 2:17 pm

Posted in Asp.Net, Web Coding

Tagged with , ,

Gridview : Empty First Row / Asp.net 2.0

leave a comment »

If you using Gridview control and your Grid doesnt have HEADER information then make sure you turn off the “ShowHeader” property for that Gridview or else you will notice a blank line on top of the grid.  If you are

If you do viewsource you will notice this mystery line <tr><th></th</tr> as first line of grid table.

Written by gchandra

September 26, 2007 at 8:32 am

Posted in Asp.Net

Tagged with ,