代码之家  ›  专栏  ›  技术社区  ›  Chris McCall

ASP.NET DataGrid,添加两个ButtonColumns,只有一个出现

  •  0
  • Chris McCall  · 技术社区  · 15 年前

    我正在尝试在旧版ASP.NET应用程序的DataGrid中的每一行添加几个按钮。

    代码如下:

    <asp:datagrid id="dgView" style="Z-INDEX: 101; LEFT: 0px; POSITION: absolute; TOP: 0px" runat="server" Width="100%" BorderColor="Black" AllowPaging="True" PageSize="8">
     <AlternatingItemStyle Font-Size="XX-Small" Font-Names="Verdana" HorizontalAlign="Center" VerticalAlign="Bottom">
     </AlternatingItemStyle>
     <ItemStyle Font-Size="XX-Small" Font-Names="Verdana" Wrap="False" HorizontalAlign="Center" Height="20px" ForeColor="Black" VerticalAlign="Bottom" BackColor="White"></ItemStyle>
     <HeaderStyle Font-Size="X-Small" Font-Names="Verdana" Font-Bold="True" HorizontalAlign="Center" Height="20px" ForeColor="#990033" VerticalAlign="Middle" BackColor="LightGray"></HeaderStyle>
     <PagerStyle Height="20px" Mode="NumericPages"></PagerStyle>
     <Columns>
      <asp:ButtonColumn ButtonType="PushButton" Text="Reprocess" CommandName="Reprocess">
      <ItemStyle Font-Size="XX-Small" Font-Bold="True" ForeColor="Blue"></ItemStyle>
      </asp:ButtonColumn>
      <asp:ButtonColumn ButtonType="PushButton" Text="Suppress" CommandName="Suppress">
      <ItemStyle Font-Size="XX-Small" Font-Bold="True" ForeColor="Blue"></ItemStyle>
      </asp:ButtonColumn>
     </Columns>
    </asp:datagrid>
    

    下面是生成的网格: alt text http://img255.imageshack.us/img255/3442/gridview.png

    其余的列来自数据绑定记录集。我不想在这上面花费任何时间,除了添加这个按钮所需要的时间之外,我只得到一天左右的时间来添加一些功能,然后我就必须继续。当我取下“抑制”按钮时,“再处理”按钮将变为可见,但似乎一次只能看到一个。问题可能是什么?

    1 回复  |  直到 15 年前
        1
  •  0
  •   Bryan    15 年前

    你确定它没有渲染吗?可能只是藏起来了。检查HTML源代码。

    如何生成其余的列?看起来它们是自动生成的…如果设置autogenerateColumns=“false”,会发生什么?你可能会得到两个buttonColumn列,嗯?