Hi, and Happy New years:
I have a RADGrid (Nov 2008 ver) control and I am attempting to inserts and update the 'detail' table. It does not automatically fire the
I have a RADGrid (Nov 2008 ver) control and I am attempting to inserts and update the 'detail' table. It does not automatically fire the
ObjectDataSource_Inserting right after the RadGrid_InsertCommand event. Any ideas? Is their a boolean flag I should or could check?
3 Answers, 1 is accepted
0

Phil
Top achievements
Rank 2
answered on 02 Jan 2009, 02:13 PM
Additional info, ... I have done this before, but using C# and this is in VB.Net. Slight differences, ... I took out the handling and used the OnInserting attribute in the datasource but not change.
0
Accepted

Kevin Babcock
Top achievements
Rank 1
answered on 02 Jan 2009, 02:21 PM
Hi Phil,
I tried to reproduce your problem but was unsuccessful. I was able to successfully handle both the RadGrid's InsertCommand and the ObjectDataSource's ItemInserting command. Here is the code I used to test this:
Default.aspx
Default.aspx.cs
ItemDataSource.cs
Perhaps this simple example will help you figure out what is going wrong with your application. If not, could you provide more details (and code samples) so that I can help you further?
Thanks,
Kevin Babcock
I tried to reproduce your problem but was unsuccessful. I was able to successfully handle both the RadGrid's InsertCommand and the ObjectDataSource's ItemInserting command. Here is the code I used to test this:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Telerik.Examples._Default" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml" > |
<head runat="server"> |
<title>Example</title> |
</head> |
<body> |
<form id="form1" runat="server"> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> |
<telerik:RadGrid ID="RadGrid1" runat="server" |
AllowAutomaticInserts="True" |
AutoGenerateColumns="False" |
DataSourceID="ObjectDataSource1" |
OnInsertCommand="RadGrid1_InsertCommand"> |
<MasterTableView |
CommandItemDisplay="TopAndBottom" |
DataKeyNames="ID"> |
<Columns> |
<telerik:GridNumericColumn |
DataField="ID" |
HeaderText="ID"> |
</telerik:GridNumericColumn> |
<telerik:GridBoundColumn |
DataField="Value" |
HeaderText="Value"> |
</telerik:GridBoundColumn> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" |
DataObjectTypeName="Telerik.Examples.Item" |
InsertMethod="Insert" |
OnInserting="ObjectDataSource1_Inserting" |
SelectMethod="Select" |
TypeName="Telerik.Examples.ItemDataSource"> |
</asp:ObjectDataSource> |
</form> |
</body> |
</html> |
Default.aspx.cs
using System.Web.UI.WebControls; |
namespace Telerik.Examples |
{ |
public partial class _Default : System.Web.UI.Page |
{ |
protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
{ |
// add additional logic here |
} |
protected void ObjectDataSource1_Inserting(object sender, ObjectDataSourceMethodEventArgs e) |
{ |
// add additional logic here |
} |
} |
} |
ItemDataSource.cs
using System.Collections.Generic; |
using System.ComponentModel; |
namespace Telerik.Examples |
{ |
[DataObject] |
public class ItemDataSource |
{ |
[DataObjectMethod(DataObjectMethodType.Select, true)] |
public IEnumerable<Item> Select() |
{ |
var items = new Item[]{ |
new Item { ID=1, Value="Something" }, |
new Item { ID=2, Value="Something Else" } |
}; |
return items; |
} |
[DataObjectMethod(DataObjectMethodType.Insert, true)] |
public void Insert(Item item) |
{ |
// Add insert code here |
} |
} |
public class Item |
{ |
public int ID { get; set; } |
public string Value { get; set; } |
} |
} |
Perhaps this simple example will help you figure out what is going wrong with your application. If not, could you provide more details (and code samples) so that I can help you further?
Thanks,
Kevin Babcock
0

Phil
Top achievements
Rank 2
answered on 02 Jan 2009, 07:28 PM
Oh drat ... AllowAutomaticInserts, I missed it, in my old sample code. I have not been coding telerik for a number of months.