Hi,
I have a simple page where I create a grid programmatically. I have to put custom column on this grid, so I simulate it in using simple CustomBoundColumn who extend GridBoundColumn.
When I manipulate the grid (paging, filtering, ...), I give this message :
Cannot create column with the specified type name: CustomBoundColumn
Here is my aspx file :
And my aspx.cs file :
What is wrong ?
Thank you !
I have a simple page where I create a grid programmatically. I have to put custom column on this grid, so I simulate it in using simple CustomBoundColumn who extend GridBoundColumn.
When I manipulate the grid (paging, filtering, ...), I give this message :
Cannot create column with the specified type name: CustomBoundColumn
Here is my aspx file :
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DynamicGrid.aspx.cs" Inherits="DEmosTelerik.DynamicGrid" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager runat="server"></telerik:RadScriptManager> <div> <asp:PlaceHolder runat="server" ID="PlaceHolder"></asp:PlaceHolder> </div> </form></body></html>And my aspx.cs file :
using System;using System.Collections.Generic;using Telerik.Web.UI;namespace DEmosTelerik{ public partial class DynamicGrid : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RadGrid grid = new RadGrid(); grid.ID = "grid"; grid.AllowPaging = true; grid.PageSize = 2; grid.MasterTableView.AutoGenerateColumns = false; grid.EnableViewState = true; grid.AllowFilteringByColumn = true; grid.PagerStyle.AlwaysVisible = true; grid.AllowSorting = true; grid.NeedDataSource += Grid_NeedDataSource; PlaceHolder.Controls.Add(grid); if (!IsPostBack) { CustomBoundColumn boundColumn; boundColumn = new CustomBoundColumn(); grid.MasterTableView.Columns.Add(boundColumn); boundColumn.DataField = "Numero"; boundColumn.HeaderText = "Numéro"; boundColumn = new CustomBoundColumn(); grid.MasterTableView.Columns.Add(boundColumn); boundColumn.DataField = "Nom"; boundColumn.HeaderText = "Nom"; boundColumn.CurrentFilterFunction = GridKnownFunction.Contains; boundColumn.DataFormatString = "<nobr>{0}<nobr>"; boundColumn.AutoPostBackOnFilter = true; boundColumn.ShowFilterIcon = false; boundColumn = new CustomBoundColumn(); grid.MasterTableView.Columns.Add(boundColumn); boundColumn.DataField = "Prenom"; boundColumn.HeaderText = "Prénom"; boundColumn.CurrentFilterFunction = GridKnownFunction.Contains; boundColumn.DataFormatString = "<nobr>{0}<nobr>"; boundColumn.AutoPostBackOnFilter = true; boundColumn.ShowFilterIcon = false; } } protected void Grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { (sender as RadGrid).DataSource = SearchEleves(); } private List<Eleve> SearchEleves() { List<Eleve> eleves = new List<Eleve>(); eleves.Add(new Eleve { Numero = 12345, Nom = "Garnier", Prenom = "Francis" }); eleves.Add(new Eleve { Numero = 1457, Nom = "Caillet", Prenom = "Jonas" }); eleves.Add(new Eleve { Numero = 5487, Nom = "Delli Gatti", Prenom = "José" }); eleves.Add(new Eleve { Numero = 8596, Nom = "Stoppani", Prenom = "Alexandre" }); eleves.Add(new Eleve { Numero = 8529, Nom = "Benoit", Prenom = "Roland" }); eleves.Add(new Eleve { Numero = 5589, Nom = "Paupe", Prenom = "Daniel" }); eleves.Add(new Eleve { Numero = 25996, Nom = "Bellanca", Prenom = "David" }); return eleves; } } public class Eleve { public decimal Numero { get; set; } public string Nom { get; set; } public string Prenom { get; set; } } public class CustomBoundColumn : GridBoundColumn { }}What is wrong ?
Thank you !
