开发者

Change the Header Text of Autogenerated Databound Column in RadGrid

开发者 https://www.devze.com 2023-04-08 15:27 出处:网络
How can i change the Header Text of Autogenerated DataBound Columns in RADGRID. I am loading a dataset whoz columns are autogenerated (Wgt1,Wgt2,Wgt3.......). I want these Column Headers as

How can i change the Header Text of Autogenerated DataBound Columns in RADGRID. I am loading a dataset whoz columns are autogenerated (Wgt1,Wgt2,Wgt3.......). I want these Column Headers as

Wgt | abc | Wgt | edg | Wgt |....... wh开发者_如何学编程ich at the moment is coming as

Wgt1 | abc | Wgt2 | edg | Wgt3 |.......

I tried

If (TypeOf e.Item Is GridDataItem) Then

  For Each column1 As GridColumn In e.Item.OwnerTableView.RenderColumns

      Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem)

           If column1.HeaderText = "Wgt1" Then

              dataItem("Wgt1").Text = "Wgt"

           End If

   Next

End If

But this is changing the Column Data and not the Header Text


    protected void RadGrid2_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            dynamic data = new[] {
                    new { ID = 1, Name ="Name1"},
                    new { ID = 2, Name = "Name2"},
                    new { ID = 3, Name = "Name3"},
                    new { ID = 4, Name = "Name4"},
                    new { ID = 5, Name = "Name5"}
                };


            RadGrid2.DataSource = data;
        }
        protected void RadGrid2_ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
        {
            if (e.Column.UniqueName == "Name")
            {
                e.Column.HeaderText = "Jayesh";
            }
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消