Note that there are some explanatory texts on larger screens.

plurals
  1. PO'EmptyDataText' tag in GridView wants to be shown only if data is not found
    text
    copied!<p>I have the following Gridview (which works) and an 'EmptyDataText' tag that should show a message on the screen if the data could not be found from the database after clicking the submit button. The problem is, the message 'no data found' is displayed on the page the moment the page is opened but I want the message to appear only if the user enters an email address which could not be found in the db. I hope I explained it correct, I can't really word this problem in a better way, pleae help!</p> <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource" EmptyDataText="The data could not be found" CellSpacing="3" CellPadding="4" GridLines="None" ForeColor="#333333"&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID"&gt; &lt;ItemStyle Font-Names="Verdana" Font-Size="9pt" /&gt; &lt;HeaderStyle Font-Names="Verdana" Font-Size="10pt" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="name" HeaderText="Name" SortExpression="name"&gt; &lt;ItemStyle Font-Names="Verdana" Font-Size="9pt" /&gt; &lt;HeaderStyle Font-Names="Verdana" Font-Size="10pt" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="EmailAddress" HeaderText="Email Address" SortExpression="EmailAddress"&gt; &lt;ItemStyle Font-Names="Verdana" Font-Size="9pt" /&gt; &lt;HeaderStyle Font-Names="Verdana" Font-Size="10pt" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="Address1" HeaderText="Address1" SortExpression="Address1"&gt; &lt;ItemStyle Font-Names="Verdana" Font-Size="9pt" /&gt; &lt;HeaderStyle Font-Names="Verdana" Font-Size="10pt" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="Address2" HeaderText="Address2" SortExpression="Address2"&gt; &lt;ItemStyle Font-Names="Verdana" Font-Size="9pt" /&gt; &lt;HeaderStyle Font-Names="Verdana" Font-Size="10pt" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="city" HeaderText="City" SortExpression="city"&gt; &lt;ItemStyle Font-Names="Verdana" Font-Size="9pt" /&gt; &lt;HeaderStyle Font-Names="Verdana" Font-Size="10pt" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="PostCode" HeaderText="Post Code" SortExpression="PostCode"&gt; &lt;ItemStyle Font-Names="Verdana" Font-Size="9pt" /&gt; &lt;HeaderStyle Font-Names="Verdana" Font-Size="10pt" /&gt; &lt;/asp:BoundField&gt; &lt;/Columns&gt; &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt; &lt;FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" /&gt; &lt;PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /&gt; &lt;SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /&gt; &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt; &lt;AlternatingRowStyle BackColor="White" ForeColor="#284775" /&gt; &lt;EditRowStyle BackColor="#999999" /&gt; &lt;/asp:GridView&gt; </code></pre> <p>This might be something quite simple, maybe something to do with the way the page refreshes? Or it might be quite difficult... I just don't really want the message to be displayed on the screen even befroe the user has enetered any info.</p> <p>Thanks.</p> <hr> <p>I'm wanting to align centre (in the gridview) the EmptyDataText="no info" tag rather than it being on the default left of the page.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload