QualiWareUA
Top achievements
Rank 1
QualiWareUA
asked on 25 Apr 2008, 03:33 PM
Hello,
I have command item template with a link in it. This link fires InsertCommand command. Server-side handler is triggered. And I have e.Item of type GridCommandItem instead of GridEditableItem. Thus I cannot extract values from it. What might be the problem and how can I fix it?
I have command item template with a link in it. This link fires InsertCommand command. Server-side handler is triggered. And I have e.Item of type GridCommandItem instead of GridEditableItem. Thus I cannot extract values from it. What might be the problem and how can I fix it?
7 Answers, 1 is accepted
0
Vladimir
Top achievements
Rank 1
answered on 26 Apr 2008, 07:22 AM
Hi Vladimir,
You can check this example for reference:
http://www.telerik.com/demos/aspnet/prometheus/Grid/Examples/DataEditing/UserControlEditForm/DefaultCS.aspx
In the command item there is a button with CommandName = "InitInsert" which will open the insert item and in the insert item you can fire "PerformInsert" command.
You can check this example for reference:
http://www.telerik.com/demos/aspnet/prometheus/Grid/Examples/DataEditing/UserControlEditForm/DefaultCS.aspx
In the command item there is a button with CommandName = "InitInsert" which will open the insert item and in the insert item you can fire "PerformInsert" command.
0
QualiWareUA
Top achievements
Rank 1
answered on 26 Apr 2008, 12:38 PM
Hello Vlad,
The problem is right here (code is taken from the sample you provided)^
The problem is right here (code is taken from the sample you provided)^
| protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) |
| { |
| GridEditableItem editedItem = e.Item as GridEditableItem; |
0
Vladimir
Top achievements
Rank 1
answered on 26 Apr 2008, 04:12 PM
0
QualiWareUA
Top achievements
Rank 1
answered on 26 Apr 2008, 07:43 PM
Vlad, and how can I do this indirectly? Or what am I doing wrong?
0
Princy
Top achievements
Rank 2
answered on 28 Apr 2008, 09:32 AM
Hi Vladimir,
A suggestion would be to set the CommandName of the link button in the CommandItemTemplate to "InitInsert ". This will set the grid in insert mode and open the insert form . Clicking the Insert button(which has a CommandName of "PerformInsert" )in the insert form will fire the InsertCommand event and you will then be able t access the form values using the GridEditableItem.
Thanks,
Princy
A suggestion would be to set the CommandName of the link button in the CommandItemTemplate to "InitInsert ". This will set the grid in insert mode and open the insert form . Clicking the Insert button(which has a CommandName of "PerformInsert" )in the insert form will fire the InsertCommand event and you will then be able t access the form values using the GridEditableItem.
Thanks,
Princy
0
QualiWareUA
Top achievements
Rank 1
answered on 28 Apr 2008, 09:51 AM
Hi Princy,
The problem that it is done this way.
And corresponding handler is called, but the type of item is GridCommandItem.
The problem that it is done this way.
| <CommandItemTemplate> |
| <div style="padding: 0 5px;"> |
| <asp:LinkButton ID="selectButton" runat="server" CommandName="Select" Visible='<%# IsForSelection %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Edit.gif" />Select</asp:LinkButton> |
| <asp:LinkButton ID="includeButton" runat="server" CommandName="Include"><img style="border:0px;vertical-align:middle;" alt="" src="Images/Edit.gif" />Include</asp:LinkButton> |
| <asp:LinkButton ID="excludeButton" OnClientClick="javascript:return confirm('Do you want to exclude selected items from query results?')" runat="server" CommandName="Exclude"><img style="border:0px;vertical-align:middle;" alt="" src="Images/Edit.gif" />Exclude</asp:LinkButton> |
| <asp:LinkButton ID="editButton" runat="server" CommandName="EditSelected" Visible='<%# itemsGridView2.EditIndexes.Count == 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Edit.gif" />Edit selected</asp:LinkButton> |
| <asp:LinkButton ID="updateButton" runat="server" CommandName="UpdateEdited" Visible='<%# itemsGridView2.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Update.gif" />Update</asp:LinkButton> |
| <asp:LinkButton ID="cancelButton" runat="server" CommandName="CancelAll" Visible='<%# itemsGridView2.EditIndexes.Count > 0 || itemsGridView2.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Cancel.gif" />Cancel editing</asp:LinkButton> |
| <asp:LinkButton ID="templateButton" runat="server" CommandName="InitInsert" Visible='<%# !itemsGridView2.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/AddRecord.gif" />Add new</asp:LinkButton> |
| <asp:LinkButton ID="createButton" runat="server" CommandName="PerformInsert" Visible='<%# itemsGridView2.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Insert.gif" /> Add this item</asp:LinkButton> |
| <asp:LinkButton ID="removeButton" OnClientClick="javascript:return confirm('Do you want to remove selected items?')" runat="server" CommandName="DeleteSelected"><img style="border:0px;vertical-align:middle;" alt="" src="Images/Delete.gif" />Delete selected items</asp:LinkButton> |
| </div> |
| </CommandItemTemplate> |
And corresponding handler is called, but the type of item is GridCommandItem.
0
Shinu
Top achievements
Rank 2
answered on 28 Apr 2008, 10:39 AM
Hi,
Try the code below to achieve the editor values:
Try the code below to achieve the editor values:
protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
{
GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();
}
Thanks,
Shinu