No records message or template doesn't show when we overide the OnCommand client event handler. It works fine if we remove the GridCommand client event handler.
Below is my simplified code:
ASPX:
| <asp:PlaceHolder ID="phGrid" runat="server"></asp:PlaceHolder> |
| <script type="text/javascript" language="javascript"> |
| function GridCommand(sender, args) { |
| } |
| </script> |
Code Behind:
| RadGrid grid; |
| protected override void OnInit(EventArgs e) |
| { |
| base.OnInit(e); |
| grid = new RadGrid(); |
| grid.ID = "grid"; |
| grid.NeedDataSource += new GridNeedDataSourceEventHandler(grid_NeedDataSource); |
| grid.ClientSettings.ClientEvents.OnCommand = "GridCommand"; |
| PopulateGridColumns(grid); |
| phGrid.Controls.Add(grid); |
| } |
| void grid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| DataTable dt = new DataTable(); |
| grid.DataSource = dt; |
| } |
| protected void PopulateGridColumns(RadGrid grid) |
| { |
| List<Field> fields = new List<Field> |
| { |
| new Field { DisplayName = "ID", ColumnName = "ID" }, |
| new Field { DisplayName = "Name", ColumnName = "Name" }, |
| new Field { DisplayName = "Description", ColumnName = "Description" }, |
| new Field { DisplayName = "Location", ColumnName = "Location" }, |
| new Field { DisplayName = "Name", ColumnName = "Name" } |
| }; |
| foreach (var field in fields) |
| { |
| #region GridBoundColumns |
| GridBoundColumn col = new GridBoundColumn(); |
| grid.MasterTableView.Columns.Add(col); |
| col.DataField = field.ColumnName; |
| col.HeaderText = field.DisplayName; |
| if (field.ColumnName == "ID") |
| col.DataType = Type.GetType("System.Int32"); |
| #endregion |
| } |
| } |
| [Serializable] |
| public class Field |
| { |
| public String ColumnName { get; set; } |
| public String DisplayName { get; set; } |
| } |
Please let me know if this an issue with the RadGrid control. Also note this is a simplified version I posted here.
Thanks,
Tilak