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

[Solved] Crash with GridTemplateColumn (bugreport)

6 Answers 368 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sergey
Top achievements
Rank 1
Sergey asked on 21 Aug 2008, 10:01 AM
This will crash (however this construction is allowed in standart asp.net grid component):

<telerik:GridTemplateColumn Visible="false">  
    <EditItemTemplate> 
            <asp:DropDownList ID="ddCategory" Runat="server" CssClass="GeneralDropDownList"></asp:DropDownList> 
    </EditItemTemplate> 
</telerik:GridTemplateColumn> 
 

System crashes on Databind with long message
System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.  
   at Telerik.Web.UI.GridTemplateColumn.FillValues(IDictionary newValues, GridEditableItem editableItem)  
   at Telerik.Web.UI.GridEditableItem.ExtractValues(IDictionary newValues)  
   at Telerik.Web.UI.GridTableView.ExtractValuesFromItem(IDictionary newValues, GridEditableItem editedItem)  
   at Telerik.Web.UI.GridItemBuilder.CreateItems(GridGroupingContext group)  
   at Telerik.Web.UI.GridTableView.CreateItems(IEnumerator enumerator, GridColumn[] columns, ControlCollection controls)  
   at Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource)  
   at Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource)  
   at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)  
   at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)  
   at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)  
   at System.Web.UI.WebControls.DataBoundControl.PerformSelect()  
   at Telerik.Web.UI.GridTableView.PerformSelect()  
   at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()  
   at Telerik.Web.UI.GridTableView.DataBind()  
   at Telerik.Web.UI.RadGrid.DataBind()  
   at System.Web.UI.Control.DataBindChildren()  
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)  
   at System.Web.UI.Control.DataBind()  
   at System.Web.UI.Control.DataBindChildren()  
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)  
   at System.Web.UI.Control.DataBind()  
   at Telerik.Web.UI.GridItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows)  
   at Telerik.Web.UI.GridItemBuilder.InitializeItem(Int32 dataSourceIndex, String& nextItemHierarchicalIndex, Boolean& itemIsInEditMode)  
   at Telerik.Web.UI.GridItemBuilder.CreateItems(GridGroupingContext group)  
   at Telerik.Web.UI.GridTableView.CreateItems(IEnumerator enumerator, GridColumn[] columns, ControlCollection controls)  
   at Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource)  
   at Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource)  
   at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)  
   at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)  
   at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)  
   at System.Web.UI.WebControls.DataBoundControl.PerformSelect()  
   at Telerik.Web.UI.GridTableView.PerformSelect()  
   at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()  
   at Telerik.Web.UI.GridTableView.DataBind()  
   at Telerik.Web.UI.RadGrid.DataBind()  
   at Sleza4eEngine.LRMup.controls.components.BFfamily.AttachmentsControl.LoadGrid(Boolean AddNew) in D:\Sleza4e\Job\SourceCode\lrmup\src\LRMup\controls\components\BFfamily\main\AttachmentsControl.ascx.cs:line 71  
   at Sleza4eEngine.LRMup.controls.components.BFfamily.AttachmentsControl.processData(XmlNode dataNode) in D:\Sleza4e\Job\SourceCode\lrmup\src\LRMup\controls\components\BFfamily\main\AttachmentsControl.ascx.cs:line 32  
   at Sleza4eEngine.LRMup.controls.content.file.LoadGroups(Boolean FilePostBack) in D:\Sleza4e\Job\SourceCode\lrmup\src\LRMup\controls\content\file.ascx.cs:line 329  
   at Sleza4eEngine.LRMup.controls.content.file.Page_Load(Object sender, EventArgs e) in D:\Sleza4e\Job\SourceCode\lrmup\src\LRMup\controls\content\file.ascx.cs:line 210  
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)  
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)  
   at System.EventHandler.Invoke(Object sender, EventArgs e)  
   at System.Web.UI.Control.OnLoad(EventArgs e)  
   at System.Web.UI.Control.LoadRecursive()  
   at System.Web.UI.Control.LoadRecursive()  
   at System.Web.UI.Control.LoadRecursive()  
   at System.Web.UI.Control.LoadRecursive()  
   at System.Web.UI.Control.LoadRecursive()  
   at System.Web.UI.Control.LoadRecursive()  
   at System.Web.UI.Control.LoadRecursive()  
   at System.Web.UI.Control.LoadRecursive()  
   at System.Web.UI.Control.LoadRecursive()  
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  
   --- End of inner exception stack trace ---  
   at System.Web.UI.Page.HandleError(Exception e)  
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  
   at System.Web.UI.Page.ProcessRequest()  
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)  
   at System.Web.UI.Page.ProcessRequest(HttpContext context)  
   at ASP.start_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\a159c958\db1b23ec\App_Web_start.aspx.cdcab7d2.3eyik7my.0.cs:line 0  
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()  
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)  
 


That took some time to me to find the reason of the problem (my current grid is quite complex)
User just need to add empty ItemTemplate. However, it was not easy to find the reason

<telerik:GridTemplateColumn Visible="false">  
<ItemTemplate> 
</ItemTemplate>   
    <EditItemTemplate> 
            <asp:DropDownList ID="ddCategory" Runat="server" CssClass="GeneralDropDownList"></asp:DropDownList> 
    </EditItemTemplate> 
</telerik:GridTemplateColumn> 
 

6 Answers, 1 is accepted

Sort by
0
Leon
Top achievements
Rank 1
answered on 21 Aug 2008, 08:30 PM
Sergey,

I think I've seen this problem posted before, do you run that with the latest Q2 2008 version? If so, you can submit a bug report to help Telerik fix that!

Thanks for posting the solution and all the best!
~Leon
0
Mohammed Imaduddin
Top achievements
Rank 1
answered on 23 Jul 2009, 04:53 PM
Thank you Sergey! You have saved my life. I have a pretty complex grid too, and this was causing me a lot of grief. I spent the last 3 hours trying to figure this out, until I read your post.  Thank you so much!

This problem is apparently not resolved. I am using the Q1 2009 version.
0
Pavel
Telerik team
answered on 29 Jul 2009, 06:08 AM
Hello Mohammed,

Could you explain what is the exact scenario that is producing the error. You can also open a support ticket and attach to it a sample website which illustrates the issue.

All the best,
Pavel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
cheburek
Top achievements
Rank 1
answered on 25 Sep 2009, 03:49 PM
Sergey, thank you so much
You really have save a couple of my head beating of wall.

I had a grid with AllowMultiRowedit="true" AllowAutomaticDeletes="True"
and
<telerik:GridTemplateColumn ReadOnly="False"  
          UniqueName="Width" SortExpression="Width" HeaderText="Width">                     
          <EditItemTemplate> 
            <asp:TextBox runat="server" id="tbEditWidth"             
             Text='<%# Bind("Width") %>' /> 
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"  
                ErrorMessage="Required" 
                ControlToValidate="tbEditWidth"  
                Display="Dynamic"  
                Enabled="True" Visible="True"/> 
            <asp:CustomValidator ID="WidthValidator1" runat="Server"  
                ControlToValidate="tbEditWidth" 
                OnServerValidate="WidthValidator1_ServerValidate"  
                Display="Dynamic"  
                Enabled="True" Visible="True" /> 
          </EditItemTemplate> 
          </telerik:GridTemplateColumn> 
calling Delete was cause the same exception. After inserting emty <ItemTemplate/> all works fine.

By the way CustomValidator handler is called properly but in handler I set error message and it does not show after validation because of one more command (EditAll) that come to server after Update command (read as One more server request) so all errors that were found when Update command came are lost on EditAll


 Private Sub RadGrid1_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand 
'EditAll 
    End Sub 
     
Protected Sub WidthValidator1_ServerValidate(ByVal source As ObjectByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) 
      If Not IsNumeric(args.Value) Then 
        args.IsValid = False 
        DirectCast(source, CustomValidator).ErrorMessage = "Value must be numeric" 
      End If 
    End Sub 

0
MiroslavStantic
Top achievements
Rank 1
Iron
answered on 11 Nov 2009, 02:16 PM
I'm using RadControls for ASP.NET AJAX Q2 2009 SP1 and I am seeing the same thing.
If I put a Template column in the grid and set Display="false" and only put an EditTemplate inside it, the grid should not throw a strange exception "Object reference not set to an instance of an object" when Delete command is raised inside the grid (by user clicking a delete button). Simple ObjectDataSource and Automatic operations are used, so it's really easy to recreate. The workaround is to give the grid an empty ItemTemplate: "<ItemTemplate></ItemTemplate>". With this strange behavior grid takes away precious developer time.

Stack trace:
System.NullReferenceException: Object reference not set to an instance of an   
object. at Telerik.Web.UI.GridTemplateColumn.FillValues(IDictionary newValues,   
GridEditableItem editableItem) at   
Telerik.Web.UI.GridEditableItem.ExtractValues(IDictionary newValues) at   
Telerik.Web.UI.GridTableView.ExtractValuesFromItem(IDictionary newValues,   
GridEditableItem editedItem) at   
Telerik.Web.UI.GridTableView.PerformDelete(GridEditableItem editedItem, Boolean   
suppressRebind) at Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object   
source) at Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) at   
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at   
Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) at   
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at   
System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) at   
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)   
at   
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String   
eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler   
sourceControl, String eventArgument) at   
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at   
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,   
Boolean includeStagesAfterAsyncPoint)  
0
Pavel
Telerik team
answered on 16 Nov 2009, 01:03 PM
Hello Miroslav,

Indeed I was able to replicate the error. I have consulted with our developers regarding this issue and they informed me that you should always add an ItemTemplate in the TemplateColumn even if it is empty. This seems to be a limitation of the current implementation.

Kind regards,
Pavel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Sergey
Top achievements
Rank 1
Answers by
Leon
Top achievements
Rank 1
Mohammed Imaduddin
Top achievements
Rank 1
Pavel
Telerik team
cheburek
Top achievements
Rank 1
MiroslavStantic
Top achievements
Rank 1
Iron
Share this question
or