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

Adding GridClientSelectColumn To RadGrid which has autogenerated columns.

2 Answers 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mustafa Beker
Top achievements
Rank 1
Mustafa Beker asked on 22 Nov 2008, 11:33 AM
Hi,

I have a radgrid on my ascx, and it has autogenerated columns.

I want to add a "GridClientSelectColumn" to RadGrid in code behind. I can add it using this code on the Page_Init method:

GridClientSelectColumn gcsc = new GridClientSelectColumn(); 
gcsc.UniqueName = "ClientSelectColumn"
gcsc.HeaderStyle.Width = Unit.Pixel(30); 
RadGrid1.MasterTableView.Columns.AddAt(0, gcsc); 

It is working, but if the page is postback, i am giving an error like this:

"Cannot create column with the specified type name: GridClientSelectColumn"

How can I solve this problem?

(My RadGrid version is 4.6.1.0)

Thanks

2 Answers, 1 is accepted

Sort by
0
SamJ
Top achievements
Rank 1
answered on 22 Nov 2008, 11:51 AM
HI,

How is your grid created, declaratively or programmatically?
If your grid is entirely created on Page.Init, then try this code:

GridClientSelectColumn gcsc = new GridClientSelectColumn();  
gcsc.UniqueName = "ClientSelectColumn";  
gcsc.HeaderStyle.Width = Unit.Pixel(30);  
RadGrid1.MasterTableView.Columns.Add(gcsc);  

If you defined the grid in the aspx directly, then try adding the column on Page.Load:

<telerik:RadGrid ID="RadGrid1" runat="server"
<telerik:RadGrid> 
protected void Page_Load(object sender, EventArgs e) 
    if(!IsPostBack) 
    { 
        GridClientSelectColumn gcsc = new GridClientSelectColumn();  
        RadGrid1.MasterTableView.Columns.Add(gcsc);  
        gcsc.UniqueName = "ClientSelectColumn";  
        gcsc.HeaderStyle.Width = Unit.Pixel(30);  
    } 

Programmatic creation


0
Mustafa Beker
Top achievements
Rank 1
answered on 24 Nov 2008, 03:03 PM
My grid is cretaed declaratively. 
And I have already used that code in "!IsPostBack" block.

When the page is loaded first time, "GridClientSelectColumn" is working normally. But if the page is postback or asynch request of grid is called by sorting, this exception is being thrown.

"Cannot create column with the specified type name: GridClientSelectColumn"


Thanks for your help.
Tags
Grid
Asked by
Mustafa Beker
Top achievements
Rank 1
Answers by
SamJ
Top achievements
Rank 1
Mustafa Beker
Top achievements
Rank 1
Share this question
or