View Full Version : [FIXED] [V0.7] Deleting rows with the ObjectDataSource

Nov 17, 2008, 3:22 PM

I try to delete rows when using ObjectDataSource, but I receive the following error under IE: 'Microsoft JScript runtime error: Object doesn't support this property or method'. My configuration is similar to your example GridPanel/DataSource Controls/Paging & Sorting. I have modified the sample to illustrate the problem. The steps to replicate this are:
- select a row on the grid
- click the Delete button
- click the Save button

The JavaScript error should show up.

How can I make this work?


<%@ Page Language="C#" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Coolite Toolkit - GridPanel with ObjectDataSource</title>
<link href="/resources/css/examples.css" rel="stylesheet" type="text/css" />

<script runat="server">
protected void Store1_RefreshData( object sender, StoreRefreshDataEventArgs e )
ObjectDataSource1.SelectParameters["start"].DefaultValue = e.Start.ToString();
ObjectDataSource1.SelectParameters["limit"].DefaultValue = e.Limit.ToString();
ObjectDataSource1.SelectParameters["sort"].DefaultValue = e.Sort;
ObjectDataSource1.SelectParameters["dir"].DefaultValue = e.Dir.ToString();


protected void ObjectDataSource1_Selected( object sender, ObjectDataSourceStatusEventArgs e )
( this.Store1.Proxy[0] as DataSourceProxy ).TotalCount = (int) e.OutputParameters["count"];

<style type="text/css">
.x-grid3-td-fullName .x-grid3-cell-inner
font-family: tahoma, verdana;
display: block;
font-weight: normal;
font-style: normal;
color: #385F95;
white-space: normal;
.x-grid3-row-body p
margin: 5px 5px 10px 5px !important;
width: 99%;
color: Gray;

<script type="text/javascript">
var fullName = function(value, metadata, record, rowIndex, colIndex, store)
return '' + record.data.LastName + ' ' + record.data.FirstName + '';

<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OnSelected="ObjectDataSource1_Selected"
SelectMethod="GetEmployeesFilter" TypeName="Coolite.Examples.Code.Northwind.Employee"
<asp:Parameter Name="start" Type="Int32" />
<asp:Parameter Name="limit" Type="Int32" />
<asp:Parameter Name="sort" />
<asp:Parameter Name="dir" />
<asp:Parameter Name="count" Direction="Output" Type="Int32" />
<asp:Parameter Name="EmployeeID" Type="Int32" />
<ext:Store ID="Store1" runat="server" AutoLoad="true" RemoteSort="true" DataSourceID="ObjectDataSource1"
<ext:Parameter Name="start" Value="={0}" />
<ext:Parameter Name="limit" Value="={3}" />
<ext:DataSourceProxy />
<ext:JsonReader ReaderID="EmployeeID">
<ext:RecordField Name="FirstName" />
<ext:RecordField Name="LastName" />
<ext:RecordField Name="Title" />
<ext:RecordField Name="TitleOfCourtesy" />
<ext:RecordField Name="BirthDate" Type="Date" />
<ext:RecordField Name="HireDate" Type="Date" />
<ext:RecordField Name="Address" />
<ext:RecordField Name="City" />
<ext:RecordField Name="Region" />
<ext:RecordField Name="PostalCode" />
<ext:RecordField Name="Country" />
<ext:RecordField Name="HomePhone" />
<ext:RecordField Name="Extension" />
<ext:RecordField Name="Notes" />
<ext:GridPanel runat="server" ID="GridPanel1" Title="Employees" Frame="true" StoreID="Store1"
<ColumnModel runat="server">
<ext:Column ColumnID="fullName" Header="Full Name" Width="150" DataIndex="LastName">
<Renderer Fn="fullName" />
<ext:Column DataIndex="Title" Header="Title" Width="150" />
<ext:Column DataIndex="TitleOfCourtesy" Header="Title Of Courtesy" Width="150" />
<ext:Column DataIndex="BirthDate" Header="BirthDate" Width="110">
<Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
<ext:Column DataIndex="HireDate" Header="HireDate" Width="110">
<Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
<ext:Column DataIndex="Address" Header="Address" Width="150" />
<ext:Column DataIndex="City" Header="City" Width="100" />
<ext:Column DataIndex="Region" Header="Region" Width="100" />
<ext:Column DataIndex="PostalCode" Header="PostalCode" Width="100" />
<ext:Column DataIndex="Country" Header="Country" Width="100" />
<ext:Column DataIndex="HomePhone" Header="HomePhone" Width="150" />
<ext:Column DataIndex="Extension" Header="Extension" Width="100" />
<ext:GridView runat="server" EnableRowBody="true">
<GetRowClass Handler="rowParams.body = '<p>'+record.data.Notes+'</p>'; return 'x-grid3-row-expanded';" />
<ext:RowSelectionModel runat="server" />
<ext:PagingToolBar ID="PagingToolBar1" runat="server" PageSize="3" StoreID="Store1"
DisplayInfo="true" DisplayMsg="Displaying employees {0} - {1} of {2}" EmptyMsg="No employees to display" />
<LoadMask ShowMask="true" />
<ext:Button ID="btnDelete" runat="server" Text="Delete" AutoPostBack="false" Icon="Delete">
<Click Handler="#{GridPanel1}.deleteSelected();" />
<ext:Button ID="Button3" runat="server" Text="Save" AutoPostBack="false" Icon="Disk">
<Click Handler="#{GridPanel1}.save();" />

This also requires adding the following method to the Employee class:

public static void DeleteEmployee(int EmployeeID)
NorthwindDataContext db = new NorthwindDataContext();
var empl = db.Employees.FirstOrDefault( e => e.EmployeeID == EmployeeID );
if ( empl != null )
db.Employees.DeleteOnSubmit( empl );
//db.SubmitChanges(); // all the related rows should be deleted before calling this method


Nov 17, 2008, 5:46 PM
Hi Tadeusz,

We found a defect. The fix has been committed to the SVN.
Please update and confirm that all works correct for you.

Thank you for bug pointing.

Nov 18, 2008, 7:51 AM
Hi Vladimir,

This has fixed the bug. Thank you.