I have a grid where the columns are created via code, not the markup. When I sort on this grid, the column header text goes blank!
I've isolated this bug into a test project, here's the complete code:
And the Code-Behind:
I've isolated this bug into a test project, here's the complete code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RadGridDynamicColumns._Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Sample Rad Grid Example</title></head><body> <form id="form1" runat="server"><telerik:RadScriptManager runat="server" /> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="gvwPlayers" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /> <telerik:RadGrid id="_radGrid" runat="server" OnNeedDataSource="radGrid_NeedDataSource" AllowSorting="true" AutoGenerateColumns="false" Width="100mm"> </telerik:RadGrid> </form></body></html>And the Code-Behind:
using System;using Telerik.Web.UI;namespace RadGridDynamicColumns{ // A test data class public class Widget { public string Name { get; set; } public string Description { get; set; } } public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this._radGrid.Columns.Add(new GridBoundColumn { HeaderText = "Name", DataField = "Name" }); this._radGrid.Columns.Add(new GridBoundColumn { HeaderText = "Description", DataField = "Description" }); } } public Widget[] TestData = new[] { new Widget { Name = "FooBar", Description = "WidgetFooBar" }, new Widget { Name = "Harold", Description = "Biggles" } }; protected void radGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) { this._radGrid.DataSource = this.TestData; } }}