我在ButtonType链接的GridView中有一个命令字段。生成的标记类似于;
<a href="javascript:__doPostBack('ctl00$GridView','Edit$0')">Edit</a>
<a href="javascript:__doPostBack('ctl00$GridView','Delete$0')">Delete</a>如何摆脱 ,它会导致我的样式出现问题。
发布于 2011-05-23 17:04:31
使用模板字段代替命令字段;
<asp:TemplateField HeaderText="Actions">
<ItemTemplate>
<asp:LinkButton runat="server" CommandName="Edit" Text="Edit" />
<asp:LinkButton runat="server" CommandName="Delete" Text="Delete" />
</ItemTemplate>
</asp:TemplateField>发布于 2016-04-26 21:57:58
不是精确的解决方案,而是一种变通办法...
我也遇到了同样的问题,因为我需要使用CommandField (而不是TemplateField),所以我设法使用ItemStyle Wrap解决了换行问题。
例如:
<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>它可以在属性ItemStyle-Wrap="false"的CommandField上,也可以作为其具有Wrap="False"属性的ItemStyle元素。
虽然,it 不会删除 ,但会应用white-space:nowrap; CSS样式,具有以下编辑时模式:
<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>希望能有所帮助。
https://stackoverflow.com/questions/6094978
复制相似问题