【问题标题】:Show 2 rows for single record in DataGid在 DataGrid 中为单个记录显示 2 行
【发布时间】:2012-06-14 12:05:07
【问题描述】:

我在 DataGrid 中有以下字段

4 绑定归档, 1 下拉菜单, 3 按钮

现在我想在一行中显示绑定字段,在第二行中显示下拉菜单和按钮。 由于某些原因,我只能使用 Datagrid。我不能使用任何其他控件。

那么我怎样才能在两行中显示数据呢?

我的代码如下:

<asp:BoundColumn DataField="Market"> </asp:BoundColumn> 
<asp:BoundColumn DataField="DrawPrice" H> </asp:BoundColumn>
<asp:BoundColumn DataField="Name2"> </asp:BoundColumn> 
<asp:BoundColumn DataField="AwayPrice"> </asp:BoundColumn> 
<asp:TemplateColumn> 
    <ItemTemplate> 
        <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
        <asp:LinkButton ID="btn1" runat="server" CommandName="btn1"/> 
        <asp:LinkButton ID="btn2" runat="server" CommandName="btn2"/> 
        <asp:LinkButton ID="btn3" runat="server" CommandName="btn3"/> 
    </ItemTemplate> 
</asp:TemplateColumn>

【问题讨论】:

  • 你到底是在用老DataGrid,还是在用GridView

标签: asp.net datagrid


【解决方案1】:

您可以将 DataGrid 中的一个单元格用作包含 2 行 2 列的 HTML 表格的容器,第二行跨越两列。

您可以使用 TemplateColumn 来实现此目的,您可以在其中放置表格的 HTML。还要为 3 个数据字段添加 &lt;%# %&gt; 绑定块(在同一个 TemplateColumn 中)。

【讨论】:

  • 您好,我不要t want to change in bound field. I cant 使用 代替绑定字段。我只能使用绑定字段。那还有其他想法吗?
  • DropDownList>
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-08-30
  • 2018-12-27
  • 2019-03-07
  • 1970-01-01
  • 2011-06-08
  • 1970-01-01
相关资源
最近更新 更多