Hi,
i need the code behind for deleting rows using Telerik gridview. Currently I have the following at the aspx page:
<telerik:GridClientDeleteColumn ConfirmText="Delete row" ButtonType="ImageButton">
what is the method called so that I construct the delete action ? now I am using only the code above - when i delete row disappears but If i do another action I get the error message invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@Page EnableEventValidation="true" %> in a page For security purposes, this feature....
I suspect that the problem is that because I havent inert any code in the code behind file .ascx
which method do I have to implement??
thanks!
i need the code behind for deleting rows using Telerik gridview. Currently I have the following at the aspx page:
<telerik:GridClientDeleteColumn ConfirmText="Delete row" ButtonType="ImageButton">
what is the method called so that I construct the delete action ? now I am using only the code above - when i delete row disappears but If i do another action I get the error message invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@Page EnableEventValidation="true" %> in a page For security purposes, this feature....
I suspect that the problem is that because I havent inert any code in the code behind file .ascx
which method do I have to implement??
thanks!
5 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 18 Mar 2014, 11:21 AM
Hi Leo,
Generally GridClientDeleteColumn is designed to delete rows client-side and submit these changes on the first post-back/ajax request.
If you want server-side approach, try any of the following :
use Autogenerated delete column
or to use GridButtonColumn
Go through the following help document links to get more details on this regard.
Deleting records
Client-side delete
Thanks,
Princy
Generally GridClientDeleteColumn is designed to delete rows client-side and submit these changes on the first post-back/ajax request.
If you want server-side approach, try any of the following :
use Autogenerated delete column
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateDeleteColumn
=
"true"
>
or to use GridButtonColumn
<
telerik:GridButtonColumn
CommandName
=
"Delete"
Text
=
"Delete"
> </
telerik:GridButtonColumn
>
Go through the following help document links to get more details on this regard.
Deleting records
Client-side delete
Thanks,
Princy
0

leo
Top achievements
Rank 1
answered on 18 Mar 2014, 12:32 PM
client-side delete is what i used but records are not actually deleted from db. just when pressed become hidden from the gridview....
0

Princy
Top achievements
Rank 2
answered on 19 Mar 2014, 03:13 AM
Hi Leo,
GridClientDeleteColumn doesn't delete the row from db. You can use the OnDeleteCommand event of the Radgrid or if you want it from clientside you can use OnCommand and catch the Delete event and handle delete yourself. Neither the GridButtonColumn, nor the GridClientDeleteColumn implement the actual deletion. You are supposed to delete the item manually as follows.
From ClientSide:
ASPX:
JS:
OR
From ServerSide:
C#:
Note that the server side event will be fired only after a postback occurs.
Thanks,
Princy
GridClientDeleteColumn doesn't delete the row from db. You can use the OnDeleteCommand event of the Radgrid or if you want it from clientside you can use OnCommand and catch the Delete event and handle delete yourself. Neither the GridButtonColumn, nor the GridClientDeleteColumn implement the actual deletion. You are supposed to delete the item manually as follows.
From ClientSide:
ASPX:
<
ClientEvents
OnCommand
=
"onCommand"
/>
JS:
<script type=
"text/javascript"
>
function
onCommand(sender, args) {
if
(args.get_commandName() ==
"Delete"
) {
//handle delete here
}
}
</script>
OR
From ServerSide:
C#:
protected
void
RadGrid1_DeleteCommand(
object
sender, GridCommandEventArgs e)
{
//Your code to delete from db
}
Thanks,
Princy
0

leo
Top achievements
Rank 1
answered on 19 Mar 2014, 04:09 PM
protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
{
//Your code to delete from db
}
this method is never called from my code...i have entered both
<telerik:GridClientDeleteColumn ConfirmText="Are you sure you want to delete the row?" HeaderStyle-Width="35px" ButtonType="ImageButton" />
and
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete"></telerik:GridButtonColumn>
in aspx but the method above is never called.
any suggestions?
0
Accepted

Princy
Top achievements
Rank 2
answered on 20 Mar 2014, 03:24 AM
Hi Leo,
Make sure that you have added OnDeleteCommand event to your RadGrid.
ASPX:
Thanks,
Princy
Make sure that you have added OnDeleteCommand event to your RadGrid.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
OnDeleteCommand
=
"RadGrid1_DeleteCommand"
>
Thanks,
Princy