ASPNET GridView如何重命名列标题? [英] ASPNET GridView how to rename column header?

查看:88
本文介绍了ASPNET GridView如何重命名列标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我真的无法想象只重命名列标题有多难。

我正在使用LINQ来查询这样的内容。


var 用户= 来自 u in Db.UserTbls 选择 û ;

Dear All,

I really can't imagine how difficult to rename just a column header.

I am using LINQ to query something like this.

var Users = from u in Db.UserTbls select u;

mGridView.DataSource = Users;

 mGridView.DataSource = Users;

mGridView.DataBind();

有一个" ;用户ID"我希望将其重命名为"用户ID"的列。剩余部分(自动生成)。

但遗憾的是,我无法轻易做到这一点。

我设法在RowCreated中重新命名。但随后它消除了其他格式化(如排序功能)。 :(

mGridView.DataBind();

There is a "UserID" column which I wish to rename to "User ID". And leave the rest (auto generated).

But unfortunately there isn't a way I can do this easily.

I manage to rename it in the RowCreated call back. But then it erased other formating (like the capability to sort). :(

推荐答案

试试这个

        With Me.GridView1
            .DataSource = ds 'DataSet
            .DataMember = "Region" 'DataTable
            .DataBind()
        End With

        With Me.GridView1.HeaderRow
            .Cells(0).Text = "Region ID"
            .Cells(1).Text = "Region"
        End With


这篇关于ASPNET GridView如何重命名列标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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