The EditCommand handler works just fine.
In looking at why the InsertCommand handler was never being hit, although a postback does occur, I discovered this in the Request.Params.
This is the target generated when I click on the Add button on the grid, it's not firing the InsertCommand because that is not what it's pointing at.
There are also no arguments on that postback. I can check for that and call something, but how do I access the individual edit text boxes displayed by the grid?
In looking at why the InsertCommand handler was never being hit, although a postback does occur, I discovered this in the Request.Params.
__EVENTTARGET: ctl00$MainContent$gridActivity$ctl00$ctl02$ctl00$InitInsertButton
This is the target generated when I click on the Add button on the grid, it's not firing the InsertCommand because that is not what it's pointing at.
There are also no arguments on that postback. I can check for that and call something, but how do I access the individual edit text boxes displayed by the grid?
7 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 16 Sep 2011, 08:03 AM
Hello Marby,
If you are using Explicit button to perform the Insert make sure that the command name that you have given is correct ("PerformInsert").
Also take a look at this help topic to see the correct names of the build-in commands of the grid.
You can also refer the following code Library that I submitted to get more details on performing manual Insert/Update/Delete operation.
Manual Insert/Update/Delete operations using Auto-generated editform with sql statements from the code-behind
Thanks,
Shinu.
If you are using Explicit button to perform the Insert make sure that the command name that you have given is correct ("PerformInsert").
Also take a look at this help topic to see the correct names of the build-in commands of the grid.
You can also refer the following code Library that I submitted to get more details on performing manual Insert/Update/Delete operation.
Manual Insert/Update/Delete operations using Auto-generated editform with sql statements from the code-behind
Thanks,
Shinu.
0
Marbry
Top achievements
Rank 1
answered on 16 Sep 2011, 02:20 PM
Thanks Shinu, but that doesn't really address the issue I'm having. The add button is auto generated, I'm not doing anything in the code behind with insert, update or delete I'm letting the default bahvior handle that and it seems to work fine.
I do need to access in the code behind the editing text boxes automatically generated when the user selects Add or Edit. It does not fire the proper event when the Add button is clicked in the first place though. And even if I check the request params for what it is passing and handle it that way, there are no arguments so I don't have a reference to the edit control that I need to get to.
Yes, under ValidationSettings.CommandsToValidate it has "PerformInsert,Update" by default.
It's just not firing the InsertCommand as it should.
I do need to access in the code behind the editing text boxes automatically generated when the user selects Add or Edit. It does not fire the proper event when the Add button is clicked in the first place though. And even if I check the request params for what it is passing and handle it that way, there are no arguments so I don't have a reference to the edit control that I need to get to.
Yes, under ValidationSettings.CommandsToValidate it has "PerformInsert,Update" by default.
It's just not firing the InsertCommand as it should.
0
Marbry
Top achievements
Rank 1
answered on 16 Sep 2011, 11:21 PM
I never got it to fire the insert command, but I was able to catch that on the ItemCommand event.
The problem I still have is trying to reference the auto generated text boxes on the rgEditRow. I figured there would be a ControlEditItems or such on the arguments, but there's not.
Event args passed in from the edit and insert event handlers.
The problem I still have is trying to reference the auto generated text boxes on the rgEditRow. I figured there would be a ControlEditItems or such on the arguments, but there's not.
Event args passed in from the edit and insert event handlers.
private void SetMaxLength(Telerik.Web.UI.GridCommandEventArgs e) { GridEditableItem item = (GridEditableItem)e.Item; for (int i = 0; i < _charFieldLength.Count; i++) { TextBox tmp = (TextBox)item[_charFieldLength[i].FieldName].Controls[0]; tmp.MaxLength = _charFieldLength[i].DataLength; } }0
Shinu
Top achievements
Rank 2
answered on 20 Sep 2011, 01:08 PM
Hello Marby,
Can you please check whether you have attached the event handler for insert command in aspx page like below.
ASPX:
C#:
-Shinu.
Can you please check whether you have attached the event handler for insert command in aspx page like below.
ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" OnInsertCommand="RadGrid1_InsertCommand" > <MasterTableView Name="Master" CommandItemDisplay="Top" "> <Columns> </Columns> </MasterTableView> </telerik:RadGrid>C#:
protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) { // your code }-Shinu.
0
Marbry
Top achievements
Rank 1
answered on 20 Sep 2011, 02:28 PM
Yes it was, I generated the handler stub it by double clicking the event in the properties window.
I've since removed that and I'm handling it as I outlined here. Autogenerated edit boxes .
I've since removed that and I'm handling it as I outlined here. Autogenerated edit boxes .
0
Martin
Top achievements
Rank 1
answered on 30 Jun 2014, 01:22 PM
I have to approve this issue here. Creating all events and setting breakpoints, you will notice, when creating the first entry by clicking on "Insert" ("Einfügen") it will first call the ItemCommand-Event with e.CommandName = "PerformInsert", but then it will NOT enter the InsertCommand event. Just create the blank events to this example and set break points:
<asp:UpdatePanel ID="upPrices" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<telerik:RadGrid ID="trgPrices" runat="server" AllowPaging="true" Culture="de-DE"
CssClass="RadGrid" AllowSorting="False" AutoGenerateColumns="false" ShowStatusBar="true" PageSize="20"
OnNeedDataSource="trgPrices_NeedDataSource"
OnItemCreated="trgPrices_ItemCreated"
OnItemDataBound="trgPrices_ItemDataBound"
OnItemCommand="trgPrices_ItemCommand"
OnEditCommand="trgPrices_EditCommand"
OnInsertCommand="trgPrices_InsertCommand"
OnUpdateCommand="trgPrices_UpdateCommand"
OnCancelCommand="trgPrices_CancelCommand"
OnDeleteCommand="trgPrices_DeleteCommand">
<MasterTableView DataKeyNames="ID" CommandItemDisplay="Top">
<CommandItemSettings ShowAddNewRecordButton="true" ShowRefreshButton="false"></CommandItemSettings>
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditColumn" EditText="Bearbeiten">
<HeaderStyle Width="20px" />
</telerik:GridEditCommandColumn>
<telerik:GridNumericColumn UniqueName="HighestQuantity" DataField="HighestQuantity" DataType="System.Int32" HeaderText="Anzahl" DefaultInsertValue="999999" MaxLength="6" NumericType="Number" />
<telerik:GridNumericColumn UniqueName="UnitPrice" DataField="UnitPrice" DataType="System.Double" HeaderText="Stückpreis" DefaultInsertValue="0" DecimalDigits="2" NumericType="Currency" />
<telerik:GridButtonColumn ButtonType="ImageButton" UniqueName="DeleteColumn" CommandName="Delete" Text="Löschen">
<HeaderStyle Width="20px" />
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings>
<EditColumn ButtonType="LinkButton" UniqueName="EditCommandColumn" InsertText="Einfügen" UpdateText="Speichern" CancelText="Abbrechen" />
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="upPrices" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<telerik:RadGrid ID="trgPrices" runat="server" AllowPaging="true" Culture="de-DE"
CssClass="RadGrid" AllowSorting="False" AutoGenerateColumns="false" ShowStatusBar="true" PageSize="20"
OnNeedDataSource="trgPrices_NeedDataSource"
OnItemCreated="trgPrices_ItemCreated"
OnItemDataBound="trgPrices_ItemDataBound"
OnItemCommand="trgPrices_ItemCommand"
OnEditCommand="trgPrices_EditCommand"
OnInsertCommand="trgPrices_InsertCommand"
OnUpdateCommand="trgPrices_UpdateCommand"
OnCancelCommand="trgPrices_CancelCommand"
OnDeleteCommand="trgPrices_DeleteCommand">
<MasterTableView DataKeyNames="ID" CommandItemDisplay="Top">
<CommandItemSettings ShowAddNewRecordButton="true" ShowRefreshButton="false"></CommandItemSettings>
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditColumn" EditText="Bearbeiten">
<HeaderStyle Width="20px" />
</telerik:GridEditCommandColumn>
<telerik:GridNumericColumn UniqueName="HighestQuantity" DataField="HighestQuantity" DataType="System.Int32" HeaderText="Anzahl" DefaultInsertValue="999999" MaxLength="6" NumericType="Number" />
<telerik:GridNumericColumn UniqueName="UnitPrice" DataField="UnitPrice" DataType="System.Double" HeaderText="Stückpreis" DefaultInsertValue="0" DecimalDigits="2" NumericType="Currency" />
<telerik:GridButtonColumn ButtonType="ImageButton" UniqueName="DeleteColumn" CommandName="Delete" Text="Löschen">
<HeaderStyle Width="20px" />
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings>
<EditColumn ButtonType="LinkButton" UniqueName="EditCommandColumn" InsertText="Einfügen" UpdateText="Speichern" CancelText="Abbrechen" />
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel>
0
Hi Martin,
As suggested I created a test website but was not able to observe any abnormalities. In my case the OnInsertCommand event was fired as expected and I was able to extract the values that the user had entered. Could you please examine the attached website and tell us what differs in your case? Additionally please test the sample and let us know if you are able to replicate the problem.
Regards,
Angel Petrov
Telerik
As suggested I created a test website but was not able to observe any abnormalities. In my case the OnInsertCommand event was fired as expected and I was able to extract the values that the user had entered. Could you please examine the attached website and tell us what differs in your case? Additionally please test the sample and let us know if you are able to replicate the problem.
Regards,
Angel Petrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.