Note that there are some explanatory texts on larger screens.

plurals
  1. POGridview - align centre the tag 'EmptyDataText' & so it's not default left of page
    text
    copied!<p>I have a gridview control in my c# program. Basically someone enters an email address and the data is then shown in the gridview but if no data could be found with the email address, a message is displayed using the EmptyDataText="no data available" tag but I cannot seem to style the text 'no data available' so it appears in the centre of the page rather than the default left. Though the CSS does seem to be working as I can change the font size and type but not text-align:center.</p> <p>I've tried a number of different options:</p> <pre><code>&lt;EmptyDataRowStyle Font-Size="12px" text-align="center" /&gt; </code></pre> <p>The problem is the text-align:center is not a valid attribute.</p> <p>Another option was:</p> <pre><code>&lt;EmptyDataRowStyle cssclass="mycentertext" /&gt; </code></pre> <p>And then I link to my style.css file and place in that:</p> <pre><code>.mycentertext {text-align: center;font-size: 12px;font-family: Verdana;} </code></pre> <p>Again, the font size changes and the font type but still not aligned.</p> <p>Please help!</p> <p>This is my gridview:</p> <pre><code>&lt;asp:GridView ID="GridView1" Visible="false" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource" EmptyDataText="No data could be found for the email address" 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;/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;EmptyDataRowStyle cssclass="mycentertext" /&gt; &lt;/asp:GridView&gt; </code></pre>
 

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