gpt4 book ai didi

c# - RowDataBound 事件中标题文本更改时的 Gridview 排序

转载 作者:太空狗 更新时间:2023-10-29 21:14:15 24 4
gpt4 key购买 nike

我的网页上有一个 GridView,其数据源是一个在运行时填充的数据表。 GridView 的 AllowSorting 属性为 True。我已经成功地为此 GridView 实现了手动排序。

但我必须将网页翻译成其他语言,并使用本地资源文件。我在 RowDataBound 事件中更改了 GridView 列的标题文本。从那时起我就无法对 GridView 进行排序。

       protected void GVSummaryTable_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.Cells.Count > 0)
{
//Translate header text
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Text = GetLocalResourceObject("GVSummaryTableName").ToString();
e.Row.Cells[1].Text = GetLocalResourceObject("GVSummaryTableLoginLevel").ToString();
e.Row.Cells[2].Text = GetLocalResourceObject("GVSummaryTableLoginID").ToString();
e.Row.Cells[4].Text = GetLocalResourceObject("GVSummaryTableDate").ToString();

}

}

}

我应该怎么做才能对列进行排序?任何帮助,将不胜感激。谢谢!

最佳答案

将代码更改为以下解决了问题:

          if (e.Row.RowType == DataControlRowType.Header) 
{
LinkButton LnkHeaderText = e.Row.Cells[1].Controls[0] as LinkButton;
LnkHeaderText.Text = "Name";
}

关于c# - RowDataBound 事件中标题文本更改时的 Gridview 排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7565801/

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