2009-07-22 168 views
1

我有一個gridview應該允許行處於編輯模式。這或多或少地取消了我認爲的中繼器的使用。ASP.net gridview multirow詳細信息標題

事情是,標題是「特殊的」。它應該有多行,其中一些單元格跨越多列。一個例子:

 
| availability monitoring | monitoring | 

| colu 1 | colu 2 | colu 3 | col 4 | col 5 | 

123是庫存狀況的部件,4和通常的監視5

牢記有在頭我心目中4行。

是否有任何方法可以實現這種類型的頭與允許編輯選項?

回答

1

首先,請你將不得不在進入模板列控制列。然後,你可以有你有想要的東西 - 一個表,文本框,複選框等

<HeaderTemplate> 
<asp:TextBox ID="TextBox1" runat="server" Text=''></asp:TextBox> 
<asp:CheckBox ID="CheckBox1" runat="server" /> 
</HeaderTemplate> 

你就必須在RowDataBound事件的進一步控制:

protected void gv_RowDataBound(object sender, GridViewRowEventArgs e) 
    { 
    if (e.Row.RowType != DataControlRowType.Header) 
      return; 

    // let the third column span over the next 2 columns. 
    e.Row.Cells[2].ColumnSpan = 3; 
    e.Row.Cells[3].Visible = false; 
    e.Row.Cells[4].Visible = false; 

    // could span more than 1 row. 
    e.Row.Cells[2].RowSpan = 2; 

等等

在一起,您可以全面控制標題部分。