Hello,
I'm getting the following javascript Ajax related error when I set up a custom iTemplate instead of using the Telerik GridTemplateColumn. The error shows up when I click on the custom link I create instead of using the aspx GridTemplateColumn's link.
Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.
The error details say it is a 500 error.
If I use the GridTemplateColumn shown below, it works fine.
But when I convert it to an iTemplate using the following code, I receive the error.
My HyperlinkTemplate is the following class.
I have an OnItemCreated event that runs the following code which adds an onclick event which I will show next and customizes the ID to make it unique:
The onclick code calls the RadAjaxManager I have set up.
The custom column is added during the Page_Load event.
It never reaches the Ajax Handler I have set up unless I use the aspx GridTemplateColumn instead of my custom template.
Am I doing something wrong with the iTemplate or am I not initializing something I should be that integrates it with the RadGrid? I've tried going through the various properties available to me for the column and the iTemplate, but I haven't had any luck making the error go away so I know I'm missing something... just not sure what.
I'm getting the following javascript Ajax related error when I set up a custom iTemplate instead of using the Telerik GridTemplateColumn. The error shows up when I click on the custom link I create instead of using the aspx GridTemplateColumn's link.
Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.
The error details say it is a 500 error.
If I use the GridTemplateColumn shown below, it works fine.
| <Columns> |
| <telerik:GridTemplateColumn UniqueName="Delete" AllowFiltering='false'> |
| <HeaderStyle Width="45px" /> |
| <ItemStyle CssClass="c" /> |
| <ItemTemplate> |
| <asp:HyperLink ID="DeleteLink" runat="server" Text="Delete" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
But when I convert it to an iTemplate using the following code, I receive the error.
| Dim type As String = "Delete" |
| Dim column As New GridTemplateColumn |
| column.AllowFiltering = False |
| column.HeaderStyle.Width = 45 |
| column.ItemStyle.CssClass = "c" |
| column.ItemTemplate = New HyperlinkTemplate(type) |
| column.UniqueName = type |
| RadGrid1.MasterTableView.Columns.Add(column) |
My HyperlinkTemplate is the following class.
| Public Class HyperlinkTemplate |
| Implements ITemplate |
| Private _type As Object |
| Public Sub New(ByVal type As String) |
| MyBase.New() |
| _type = type |
| End Sub |
| Public Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn |
| Dim hl As New HyperLink |
| hl.EnableViewState = False |
| hl.ID = _type & "Link" |
| hl.Text = _type |
| hl.Attributes("href") = "#" |
| container.Controls.Add(hl) |
| End Sub |
| End Class |
I have an OnItemCreated event that runs the following code which adds an onclick event which I will show next and customizes the ID to make it unique:
| Dim deleteLink As HyperLink = DirectCast(e.Item.FindControl("DeleteLink"), HyperLink) |
| deleteLink.Attributes("onclick") = [String].Format("return Delete('{0}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)(IDcolumnIsHere)) |
| deleteLink.ID &= e.Item.ItemIndex |
The onclick code calls the RadAjaxManager I have set up.
| function Delete(id) { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Grid,Delete," + customValue + "," + id); } |
The custom column is added during the Page_Load event.
It never reaches the Ajax Handler I have set up unless I use the aspx GridTemplateColumn instead of my custom template.
Am I doing something wrong with the iTemplate or am I not initializing something I should be that integrates it with the RadGrid? I've tried going through the various properties available to me for the column and the iTemplate, but I haven't had any luck making the error go away so I know I'm missing something... just not sure what.