GridView CommandField删除不间断空格

问题描述

| 我在ButtonType链接的GridView中有一个命令字段。产生的标记类似于;
<a href=\"javascript:__doPostBack(\'ctl00$GridView\',\'Edit$0\')\">Edit</a>&nbsp;
<a href=\"javascript:__doPostBack(\'ctl00$GridView\',\'Delete$0\')\">Delete</a>
我如何摆脱ѭ1字样,导致我的样式出现问题。     

解决方法

使用模板字段而不是命令字段;
<asp:TemplateField HeaderText=\"Actions\">
      <ItemTemplate>
         <asp:LinkButton runat=\"server\" CommandName=\"Edit\" Text=\"Edit\" />
         <asp:LinkButton runat=\"server\" CommandName=\"Delete\" Text=\"Delete\" />
      </ItemTemplate>
 
  </asp:TemplateField>
    ,不是精确的解决方案,而是解决方法... 我遇到了同样的问题,由于我需要使用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>
它可以是CommandField属性“ 4”,也可以是其带有5属性的ItemStyle元素。 虽然,它不会删除
&nbsp;
,但会应用
white-space:nowrap;
CSS样式,在“编辑”模式下具有以下内容:
<td style=\"width:48px;white-space:nowrap;\">
    <input type=\"image\" name=\"GridView1$ctl02$ctl00\" src=\"images/update.png\" alt=\"Update\">
    &nbsp;
    <input type=\"image\" src=\"images/cancel.png\" alt=\"Cancel\" onclick=\"javascript:__doPostBack(\'GridView1\',\'Cancel$0\');return false;\">
</td>
希望能帮助到你。     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...