
Javier Sosa
Top achievements
Rank 1
Javier Sosa
asked on 07 Oct 2010, 03:25 PM
I have a radgrid with an objectdatasource that binds to an entity list.
We are trying to insert a new record, but the insert command never fires.
The update and delete commands work perfectly it's just the insert that is failing.
We've got allowautomaticinsert = true, and the commandname of the button is "insert".
Please advise.
We are trying to insert a new record, but the insert command never fires.
The update and delete commands work perfectly it's just the insert that is failing.
We've got allowautomaticinsert = true, and the commandname of the button is "insert".
Please advise.
5 Answers, 1 is accepted
0
Hello Javier,
Do you handle grid CRUD operation at one place, either in the specific event handle or in the ItemCommand event but both.
However, if you can provide the code for the ItemCommand and InsertCommand event handles in your case, we can check it and turn back to you with our findings.
Best wishes,
Pavlina
the Telerik team
Do you handle grid CRUD operation at one place, either in the specific event handle or in the ItemCommand event but both.
However, if you can provide the code for the ItemCommand and InsertCommand event handles in your case, we can check it and turn back to you with our findings.
Best wishes,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Javier Sosa
Top achievements
Rank 1
answered on 07 Oct 2010, 03:57 PM
All the CRUD operations are handled in the binding layer of the entity completely separate from the grid.
There are no events handlers for ItemCommand and InsertCommand. All the CRUD events are passed directly to the objectdatasource and are handled in the binding layer. We can trace both update and delete to this layer, but the insert doesn't even trigger the event.
What is the commandname supposed to be for the update button? We've tried "Insert" and "Add". I've attached the code below.
There are no events handlers for ItemCommand and InsertCommand. All the CRUD events are passed directly to the objectdatasource and are handled in the binding layer. We can trace both update and delete to this layer, but the insert doesn't even trigger the event.
What is the commandname supposed to be for the update button? We've tried "Insert" and "Add". I've attached the code below.
<
telerik:RadGrid
ID
=
"RgCRcategories"
runat
=
"server"
DataSourceID
=
"objds"
AllowMultiRowEdit
=
"True"
GridLines
=
"None"
AllowPaging
=
"True"
AllowAutomaticUpdates
=
"true"
AllowAutomaticInserts
=
"true"
AllowAutomaticDeletes
=
"true"
AllowSorting
=
"True"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
DataSourceID
=
"objds"
DataKeyNames
=
"CategoryId"
EditMode
=
"EditForms"
CommandItemDisplay
=
"Top"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
/>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
></
CommandItemSettings
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
HeaderText
=
"Edit"
/>
<
telerik:GridBoundColumn
DataField
=
"CategoryID"
DataType
=
"System.Int32"
HeaderText
=
"Category ID"
ReadOnly
=
"True"
SortExpression
=
"CategoryID"
UniqueName
=
"CategoryID"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CRCategoryTypeID"
DataType
=
"System.Int32"
HeaderText
=
"Category Type ID"
ReadOnly
=
"True"
SortExpression
=
"CRCategoryTypeID"
UniqueName
=
"CRCategoryTypeID"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Description"
HeaderText
=
"Description"
SortExpression
=
"Description"
UniqueName
=
"Description"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"Active"
SortExpression
=
"Active"
DataField
=
"Active"
HeaderText
=
"Active"
>
<
ItemTemplate
>
<%# IIf((Eval("Active").ToString = "Y"), "Yes", "No")%>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridButtonColumn
CommandName
=
"Delete"
ButtonType
=
"ImageButton"
HeaderText
=
"Deactivate"
ConfirmText
=
"Are you sure you want to deactivate this category?"
ConfirmDialogType
=
"RadWindow"
>
</
telerik:GridButtonColumn
>
</
Columns
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
EditColumn
UniqueName
=
"EditCommandColumn1"
>
</
EditColumn
>
<
FormTemplate
>
<
table
cellspacing
=
"2"
cellpadding
=
"1"
width
=
"100%"
border
=
"0"
>
<
tr
>
<
td
>
<
b
>
<
asp:Label
Width
=
"200px"
ID
=
"lblID"
runat
=
"server"
Text='<%# Bind("CategoryId") %>'
Visible="false"></
asp:Label
>
</
b
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Category:
</
td
>
<
td
>
<
asp:TextBox
Width
=
"200px"
ID
=
"txtDescription"
runat
=
"server"
Text='<%# Bind("Description") %>'></
asp:TextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Category Type:
</
td
>
<
td
>
<
asp:DropDownList
ID
=
"ddlCategoryType"
runat
=
"server"
>
</
asp:DropDownList
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Active:
</
td
>
<
td
>
<
asp:RadioButtonList
ID
=
"radListActive"
runat
=
"server"
RepeatDirection
=
"Horizontal"
>
<
asp:ListItem
Text
=
"Yes"
Value
=
"Y"
>Yes</
asp:ListItem
>
<
asp:ListItem
Text
=
"No"
Value
=
"N"
>No</
asp:ListItem
>
</
asp:RadioButtonList
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
>
<
asp:Button
ID
=
"Button1"
runat
=
"server"
Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "InitInsert", "Update") %>'
CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "initInsert", "Update") %>'>
</
asp:Button
>
<!--<asp:Button ID="testbutton" runat="server" Text="Insert(test)" CommandName="InitInsert" />-->
<
asp:Button
ID
=
"Button2"
runat
=
"server"
Text
=
"Cancel"
CausesValidation
=
"false"
CommandName
=
"Cancel"
>
</
asp:Button
>
</
td
>
</
tr
>
</
table
>
</
FormTemplate
>
</
EditFormSettings
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:ObjectDataSource
id
=
"objds"
runat
=
"server"
ConvertNullToDBNull
=
"True"
SelectMethod
=
"Load"
InsertMethod
=
"Add"
DeleteMethod
=
"Deactivate"
UpdateMethod
=
"Update"
DataObjectTypeName
=
"vRIS.Data.Entities.CRCategoriesEntity"
TypeName
=
"vRIS.Business.Bindings.CRCategoriesDatasource"
>
</
asp:ObjectDataSource
>
0

Princy
Top achievements
Rank 2
answered on 08 Oct 2010, 01:37 PM
Hello Javier,
You need to set the CommandName as 'PerformInsert' to perform the insert operation.
ASPX:
Thanks,
Princy.
You need to set the CommandName as 'PerformInsert' to perform the insert operation.
ASPX:
<
asp:Button
ID
=
"Button1"
runat
=
"server"
Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>' CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update") %>'>
</
asp:Button
>
Thanks,
Princy.
0

Javier Sosa
Top achievements
Rank 1
answered on 08 Oct 2010, 03:55 PM
Thank you, that kinda solves the issue.
Now it triggers the InsertCommand event handler on the page. But does not trigger the insert method of the datasource. Now I'm having to write a handler specifically for the insert command when it should be handled with the datasource which passes the object directly to the databinding layer. Is there any reason why this only happens with insert while update and delete work as they should?
Javier
Now it triggers the InsertCommand event handler on the page. But does not trigger the insert method of the datasource. Now I'm having to write a handler specifically for the insert command when it should be handled with the datasource which passes the object directly to the databinding layer. Is there any reason why this only happens with insert while update and delete work as they should?
Javier
0
Hello Javier,
Go through the help article below which elaborates on this subject and see if it works for you.
Insert/Update/Delete at database level with queries
Regards,
Pavlina
the Telerik team
Go through the help article below which elaborates on this subject and see if it works for you.
Insert/Update/Delete at database level with queries
Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items