2011-12-02 130 views
0

我需要在頁腳模板中彼此之下的總數。應該有數據行,直到第5列後無網格線,然後再總上校網格視圖格式化

後網格線下面是ASPX代碼:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" SelectedRowStyle-BackColor="AliceBlue" 
ShowFooter="True" EnableModelValidation="True" 
    onrowdatabound="LineItemGrid_RowDataBound" onrowcommand="GridView1_RowCommand" CellSpacing="0" 
    style="border-width:2px;border-style:Solid;font-weight:bold;width:1050px;"> 
<Columns> 
<asp:TemplateField HeaderText="xxx"> 
<ItemTemplate> 
<asp:Label ID="lbl1" runat="server" Text='Label' ></asp:Label> 
</ItemTemplate> 

<asp:TemplateField HeaderText="yyyy"> 
<ItemTemplate> 
<asp:Label ID="lbl2" runat="server" Text='Label' ></asp:Label> 
</ItemTemplate> 
    </asp:TemplateField> 

    ///....Two other template fields here.... 
</asp:TemplateField> 
<ItemTemplate> 
<asp:Label ID="lbltotal" runat="server" Text='' ></asp:Label> 
</ItemTemplate> 
<FooterTemplate> 
    <asp:TextBox runat="server" ID="txttotalprice" ReadOnly="true" Width="100px" BorderStyle="None" ></asp:TextBox> 
</FooterTemplate> 

    </asp:TemplateField> 

</Columns> 

</asp:GridView> 

Pleaes幫助我如何在頁腳模板中應用以下要求的格式...

+1

似乎它並沒有我,你是需要分頁,排序或任何特定的Gridview功能。在這種情況下,爲什麼不建立自己的HTML表格並按照您的要求進行設計?只是一個想法。 –

+0

尋呼將包括在內 – Janet

+0

這並不是那麼簡單。你應該看的是GridView_RowDataBound事件。每次綁定一行時,都會觸發此事件,並從傳遞的Row對象中訪問單元。然後你可以遍歷每個單元格並設置一個CSS樣式。使用不同類型的控件可能會更容易,但是,正如您所說,您可能需要分頁等 – dash

回答

0

訂閱GridView_RowDataBound事件

然後,您可以這樣做:(!和CSS)

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    if (e.Row.RowType == DataControlRowType.DataRow) 
    { 
    for(int i = 0; i < e.Row.Cells.Count; i++) 
    { 
     if(i > 5) 
     { 
     e.Row.Cells[i].CssClass = "CellBorder";  
     } 
    } 

    } 

} 

您需要使用索引和條件,發揮