Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2700
Unable to cast object error when refreshing WebDataGrid
posted

Hi,

I have a WebDataGrid and was running Infragistics 11.1 2225 but today upgraded to the 2238 service pack and now have an issue.  My WebDataGrid has a number of columns including a template column containing a button.  When I click the button the idea is that a server side function is called which updates the item in the grid and then refreshes the data source for the grid.  This was working fine using :-

protected void btnCompleteTask_OnClick(object sender, EventArgs e)
{
// get the task to be deleted
int taskId = Convert.ToInt32(tbTaskID.Text);
JobTask task = new JobTask(taskId);

// Switch the complete state of the task
task.CompleteTask(!task.Complete, DateTime.Now.Date);

// Best databind again to update the display
JobTaskList listTasks = JobTaskList.GetForJob(_job.Id);
gridTasks.Rows.Clear();
gridTasks.DataSource = listTasks;
gridTasks.DataBind();
}

Now when I run my application and click the button I get an exception as shown below :-

[InvalidCastException: Unable to cast object of type 'Infragistics.Web.UI.GridControls.GridRecordItem' to type 'Infragistics.Web.UI.Framework.UIObject'.]
   Infragistics.Web.UI.TemplateContainer.OnBubbleEvent(Object source, EventArgs args) +94
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) +111
   System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +176
   System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
Am I going to have to back out the update as I can't seem to get this to work anymore.  f I take out the Rows.Clear() call I do not get the exception but neither does the grid row update to reflect the change just made.
  • 9190
    Suggested Answer
    Offline posted

    Hi,

    Thank you for posting on our forums.

    I was able to reproduce this issue using Infragistics for ASP.NET build 2238 as you've mentioned. Please note, this version of our product is no longer maintained or supported. I tried version 12.1.20121.2236 and was able to run without the exception. This makes me believe that this has since been resolved with a newer version of our product. If you wish to update you web application without encountering this exception, please update to 12.2 or newer.

    If you want to learn more about our product lifecycle, please refer to the link below:
    http://www.infragistics.com/help/product-lifecycle/