Posts Tagged ‘gridview’
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.
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.
Gridview : Empty First Row / Asp.net 2.0
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.