本文介绍了我可以合并页脚在GridView的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绑定了数据集的GridView。我有我的页脚,whichis分开列线。我想合并2列;我该怎么办呢?

 < ASP:模板列HEADERTEXT =名称SORTEX pression =名称>
<的ItemTemplate>
...
< / ItemTemplate中>
< FooterTemplate>
累计:
< / DIV>
< / FooterTemplate>
< / ASP:的TemplateField>
< ASP:模板列HEADERTEXT =时代SORTEX pression =时代>
<的ItemTemplate>
...
< / ItemTemplate中>
< FooterTemplate>
<%#GetTotal()%>
< / DIV>
< / FooterTemplate>
< / ASP:的TemplateField>
 

解决方案

未经检验的code

1日页脚模板应包括<%#GetTotal()%>

第二页脚模板应该是空的。

 保护小组Page_SaveStateComplete(BYVAL发件人为对象,BYVALË作为System.EventArgs)把手Me.SaveStateComplete
        昏暗DG作为GridView控件= GridView1
            昏暗TBL如表= DG.Controls(0)
            昏暗TR作为GridViewRow
            昏暗我作为整数
            昏暗Ĵ作为整数

TR = Tbl.Rows(Tbl.Rows.Count  -  1)这一行假设最后一行是页脚行

                    tr.Cells(0).ColumnSpan = 2',如果你有3列,然后合并单元格= 3,而不是

                    对于j = 1至1',如果你有3列则j = 1〜2,而不是
                        tr.Cells(J)。可见=假
                    下一个

    结束小组
 

I have a GridView that is bound with a dataset. I have my footer, whichis separated by the column lines. I want to merge 2 columns; how do I do that?

<asp:TemplateField HeaderText="Name" SortExpression="Name">
<ItemTemplate>
...  
</ItemTemplate>
<FooterTemplate >                    
Grand Total:
</div>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Age" SortExpression="Age">
<ItemTemplate>
...  
</ItemTemplate>
<FooterTemplate >                    
<%# GetTotal() %> 
</div>
</FooterTemplate>
</asp:TemplateField>
解决方案

untested code

1st footer template should include <%# GetTotal() %>

2nd footer template should be empty

    Protected Sub Page_SaveStateComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SaveStateComplete
        Dim DG As GridView = GridView1
            Dim Tbl As Table = DG.Controls(0)
            Dim tr As GridViewRow
            Dim i As Integer
            Dim j As Integer

tr = Tbl.Rows(Tbl.Rows.Count - 1) 'this line assume last row is footer row

                    tr.Cells(0).ColumnSpan = 2 'if you have 3 columns then colspan = 3 instead

                    For j = 1 To 1 'if you have 3 columns then j = 1 To 2 instead
                        tr.Cells(j).Visible = False
                    Next

    End Sub

这篇关于我可以合并页脚在GridView的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 00:41