radgrid dynamically add GridHTMLEditorColumn problem- Please help

2 posts, 0 answers
  1. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 20 Nov 2010 Link to this post

    I need to dynamically add GridHTMLEditorColumn to Radgrid and got error when click the edit button on the grid:

    Cannot create column with the specified type name: GridHTMLEditorColumn 

    If I change the bundColumn to GridBoundColumn, then no error . Please help!!

     

     

     


    -----------------

    below is my code:

     

     

     

     

     

    protected void Page_Load(object sender, EventArgs e)

     

     

     

     

     

     

    GridHTMLEditorColumn boundColumn = new GridHTMLEditorColumn();

     

    boundColumn.DataField =

    "French";

     

    boundColumn.HeaderText =

    "French";

     

    boundColumn.UniqueName =

    "French";

     

     

    this.RadGrid1.MasterTableView.Columns.Add(boundColumn);

     

    }


     

     

    protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)

     

    {

     

     

    //bind grid to db
    DataSet
    ds;
    ds =
    SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString, "sp_Languages_Get"); 

     

    RadGrid1.DataSource = ds;

    }

     


     

    <

     

    html xmlns="http://www.w3.org/1999/xhtml">

     

    <

     

    head runat="server">

     

     

     

     

     

    <title></title>

     

    </

     

    head>

     

    <

     

    body>

     

     

     

     

     

    <form id="form1" runat="server">

     

     

     

     

     

    <div>

     

     

     

     

     

     

    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">

     

     

     

     

     

    </telerik:RadScriptManager>

     

     

     

     

     

    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"

     

     

    GridLines="None" onneeddatasource="RadGrid1_NeedDataSource">

     

    <

     

    MasterTableView autogeneratecolumns="True">

     

    <

     

    RowIndicatorColumn>

     

    <

     

    HeaderStyle Width="20px"></HeaderStyle>

     

    </

     

    RowIndicatorColumn>

     

    <

     

    ExpandCollapseColumn>

     

    <

     

    HeaderStyle Width="20px"></HeaderStyle>

     

    </

     

    ExpandCollapseColumn>

     

     

     

     

     

    <Columns>

     

     

     

     

     

    <telerik:GridEditCommandColumn>

     

     

     

     

     

    </telerik:GridEditCommandColumn>

     

     

     

     

     

    <telerik:GridButtonColumn CommandName="Delete" Text="Delete"

     

     

    UniqueName="column">

     

     

     

     

     

    </telerik:GridButtonColumn>

     

     

     

     

     

    </Columns>

     

    </

     

    MasterTableView>

     

     

     

     

     

    </telerik:RadGrid>

     

     

     

     

     

     

    </div>

     

     

     

     

     

    </form>

     

    </

     

    body>

     

    </

     

    html>

     

     

     


    Thanks

  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 24 Nov 2010 Link to this post

    Hi Jessie,

    When the RadGrid structure is created dynamically into the code behind you have two options:
    Creating RadGrid on Page_Load - the columns or detail tables should be added to the corresponding collection first and then values for the properties of this instance should be set. Remember to check the condition (Not IsPostBack) to avoid adding the same structure objects to the grid twice.
    Creating RadGrid on Page_Init - the grid columns should be added to the Controls collection of the MasterTableView after their attributes are set.
    More information you could find on the following online documentation article:
    http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html#Creating_the_grid_entirely_in_the_code_behind

    Additionally I am sending you a simple example which demonstrates how to achieve the desired functionality.

    Sincerely yours,
    Radoslav
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top