小编KhD*_*KhD的帖子

在RowDataBound事件中更改标题文本时的Gridview排序

我的网页上有一个GridView,其DataSource是一个在运行时填充的DataTable.GridView的AllowSorting属性为True.我已经成功实现了这个GridView的手动排序.

但我不得不将网页翻译成我使用本地资源文件的其他语言.我在RowDataBound事件中更改了GridView列的Header文本.从那时起,我无法对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();

        }

    }

}
Run Code Online (Sandbox Code Playgroud)

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

c# asp.net gridview

6
推荐指数
1
解决办法
4953
查看次数

标签 统计

asp.net ×1

c# ×1

gridview ×1