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

Creating Grid on the page OnInit handler

3 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 19 Sep 2010, 11:21 AM
Hi,

I am creating a grid programmatically on the OnInit handler so that my template columns are captured in the ViewState. I am also trying to incorporate 'google-like' filtering, so I need to access the OnColumnCreating handler in the codebehind. However, when I try to add a handler to it, I am told that I cannot do it as OnColumnCreating is protected.
My code is as follows, fairly simple:

    Protected Sub Page_Init(ByVal s As Object, ByVal e As System.EventArgs) Handles Me.Init
  
            Dim rg As New RadGrid
            rg.AutoGenerateColumns = False
            rg.GridLines = GridLines.None
            rg.AllowPaging = True
            rg.AllowSorting = True
            rg.AllowFilteringByColumn = True
            rg.ShowStatusBar = True
            rg.CssClass = "RadGrid"
            rg.Skin = "WebBlue"
            rg.Width = "880"
            rg.GroupingSettings.CaseSensitive = False
  
            AddHandler rg.OnColumnCreating, AddressOf rg_ColumnCreating
  
End Sub

Can anyone help?

Many thanks!

3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 21 Sep 2010, 09:36 AM
Hi Mark,

When you have template columns in the grid and you want to create them dynamically, you need create the entire grid on Page_Init as described in this article and as you already did.
However in the demo the template columns are added dynamically on Page_Load. Therefore they are recreated in the ColumnCreating event. However this is not required in your case with the Page_Init structure creation.

All the best,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mark
Top achievements
Rank 1
answered on 21 Sep 2010, 03:05 PM
Hi,

Thanks for the reponse.

Sorry, I should have been clearer, the event I mentioned was only an example. I cannot wire up the OnItemCommand either. I need to do this to get the filtering working, as the code behind these handlers is integral.

What I'm trying to do is use this method (http://www.telerik.com/help/aspnet-ajax/grdgooglelikefiltering.html), and for the most part it's working, in fact if I had no template columns there wouldn't be a problem! It's because I have a template column that I need to create the whole thing programmatically as, if I don't, the template column appears properly when ithe grid loads, but vanishes with a postback.
0
Iana Tsolova
Telerik team
answered on 24 Sep 2010, 09:01 AM
Hi Mark,

Can you open a formal support ticket and send us a runnable sample there for further debugging and investigation.

All the best,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Mark
Top achievements
Rank 1
Share this question
or