GridView CommandField remove None-breaking space
I have a command field in a GridView that is of ButtonType link. The markup that is produced is similar to;
<a href="javascript:__doPostBack('ctl00$GridView','Edit$0')">Edit</a>
<a h开发者_如何学JAVAref="javascript:__doPostBack('ctl00$GridView','Delete$0')">Delete</a>
How do I get rid of the
it is causing problems with my styles.
use template field instead of command field;
<asp:TemplateField HeaderText="Actions">
<ItemTemplate>
<asp:LinkButton runat="server" CommandName="Edit" Text="Edit" />
<asp:LinkButton runat="server" CommandName="Delete" Text="Delete" />
</ItemTemplate>
</asp:TemplateField>
Not the precise solution but a Workaround...
I had the same issue, and since I needed to use a CommandField (and not a TemplateField), I managed to solve the line break using the ItemStyle Wrap.
For example:
<asp:CommandField ButtonType="Image" ShowEditButton="True" EditImageUrl="~/images/edit.png" CancelImageUrl="~/images/cancel.png" UpdateImageUrl="~/images/update.png" ItemStyle-Wrap="false" >
<ItemStyle Wrap="False" Width="48px"></ItemStyle>
</asp:CommandField>
It can be either on the CommandField the attribute ItemStyle-Wrap="false"
, or as its ItemStyle element with Wrap="False"
attribute.
Although, it does not remove the
, but applies the white-space:nowrap;
CSS style, having the following when Edit mode:
<td style="width:48px;white-space:nowrap;">
<input type="image" name="GridView1$ctl02$ctl00" src="images/update.png" alt="Update">
<input type="image" src="images/cancel.png" alt="Cancel" onclick="javascript:__doPostBack('GridView1','Cancel$0');return false;">
</td>
Hope it helps.
精彩评论