创建ASP.NET表头行 [英] Creating ASP.NET table header row

查看:108
本文介绍了创建ASP.NET表头行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么,这是行不通的。我试图创建从后端code表头部分,但一切都进入TBODY。

I don't know why this isn't working. I'm trying to create a table header section from the back end code, but everything is going into tbody.

        Dim output As New Web.UI.WebControls.Table

        'Create the header row
        Dim hRow As New Web.UI.WebControls.TableHeaderRow
        hRow.TableSection = Web.UI.WebControls.TableRowSection.TableHeader
        hRow.Controls.Add(New Web.UI.WebControls.TableHeaderCell)

        For Each d As GridDate In Dates
            Dim hCell As New Web.UI.WebControls.TableHeaderCell
            hCell.Text = d.Value
            hRow.Controls.Add(hCell)
        Next
        output.Controls.Add(hRow)

结果是在TBODY的一切,尽管创建一个标题行,并设置部分属性为标题。我在做什么错了?

The result is everything under tbody despite creating a header row and setting the section property to header. What am I doing wrong?

推荐答案

有是在code我发布一个错误。在我的code的最后一行,我追加新行控件集合:

There was an error in the code I posted. In the last line of my code I was appending the new row to the controls collection:

output.Controls.Add(hRow)

不要这样做。这似乎绕过某些到ASP.NET TableRows独特的属性在最后人丁。在这种情况下,它被忽略,尽管被正确地设置TableSection属性。你应该追加行对行的集合,而不是:

Don't do this. It seems to bypass some of the properties unique to ASP.NET TableRows in final rending. In this case, it was ignoring the TableSection property despite being set correctly. You should append rows to the Rows collection instead:

output.Rows.Add(hRow)

这篇关于创建ASP.NET表头行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆