gpt4 book ai didi

asp.net - ASP.NET 2.0-带tbody/thead的DataGrid

转载 作者:行者123 更新时间:2023-12-04 13:35:50 24 4
gpt4 key购买 nike

有没有一种方法可以使DataGrid控件呈现tbody和thead HTML元素?

最佳答案

虽然我喜欢“user186197”的答案,但该博客文章使用了反射,但是在非完全信任的托管环境中可能会出错。这是我们使用的东西,没有黑客:

public class THeadDataGrid : System.Web.UI.WebControls.DataGrid
{
protected override void OnPreRender(EventArgs e)
{
this.UseAccessibleHeader = true; //to make sure we render TH, not TD

Table table = Controls[0] as Table;

if (table != null && table.Rows.Count > 0)
{
table.Rows[0].TableSection = TableRowSection.TableHeader;
table.Rows[table.Rows.Count - 1].TableSection = TableRowSection.TableFooter;
}

base.OnPreRender(e);
}
}

关于asp.net - ASP.NET 2.0-带tbody/thead的DataGrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/562010/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com