Trailing space while using "headertemplate" in asp gridview <p>I have a gridview which is bounded as </p> <pre><code>&lt;asp:GridView runat="server" ID="gvShipDetails" AutoGenerateColumns="false" OnRowDataBound="gvShipDetails_RowDataBound"&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;HeaderTemplate&gt; Ship name &lt;br /&gt; &lt;asp:TextBox class="search_textbox" runat="server" BorderStyle="None" Width="100%"&gt; &lt;/asp:TextBox&gt; &lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;%#Eval("VesselName")%&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>The problem is the finally rendered html table td is rendered as</p> <pre><code>&lt;td&gt; sample vessel name &lt;/td&gt; </code></pre> <p>A lot of spaces inside td.How is this possible.<br> If I replace this bound code as</p> <pre><code>&lt;asp:BoundField HeaderText="vessel name" DataField="vesselname" /&gt; </code></pre> <p>Then html is renderd as <code>&lt;td&gt;sample vessel name&lt;td&gt;</code></p> <p>Why is it so? I wanted to use headertemplate and i wanted to avoid these trailing spaces. How to do it</p> <p>Any help will be appreciated</p>