This is a migrated thread and some comments may be shown as answers.

radgrid dynamically add GridHTMLEditorColumn problem- Please help

1 Answer 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 1
JJ asked on 20 Nov 2010, 06:14 PM
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

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 24 Nov 2010, 12:04 PM
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.
Tags
Grid
Asked by
JJ
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or