Please use CommandName="Delete" instead of
CommandName="DeleteResources".
If buttons within a GridView control invokes some of the built-in functionality of the control, you have to set the
CommandName property of a button to one of the values: "Cancel","Delete","Edit","Page","Select","Sort","Update".
Smadhu
Member
511 Points
998 Posts
i m not able to delete from database
Apr 24, 2012 05:37 AM|LINK
asp.net <asp:GridView ID="GV_Resources" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSourceResource" CssClass="EventGrid" AlternatingRowStyle-CssClass="alt" EnableModelValidation="True" Width="779px" AllowPaging="True"> <AlternatingRowStyle CssClass="alt"></AlternatingRowStyle> <PagerStyle CssClass="pgr" HorizontalAlign="Right" /> <Columns> <asp:BoundField DataField="Id" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" Visible="False" /> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" ItemStyle-Width="605px" /> <asp:ButtonField ButtonType="Button" CommandName="EditResources" Text="Edit" ControlStyle-CssClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" /> <asp:TemplateField ItemStyle-Width="" ShowHeader="False"> <ItemTemplate> <asp:Button ID="Delete" runat="server" CausesValidation="False" CommandArgument='<%# Bind("Id") %>' CommandName="DeleteResources" Text="Delete" OnClientClick="javascript:return deleteItem(this.name);" CssClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> vb.net Protected Sub Gv_Catogary_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GV_Resources.RowCommand Dim currentCommand As String = e.CommandName If currentCommand = "EditResources" Then ElseIf currentCommand = "DeleteResources" Then Dim ID As Integer = Int32.Parse(e.CommandArgument) ResourcesHelper.DeleteResource(ID) GV_Resources.DataBind() End If End SubIts not deleting from database
coolpal9
Member
164 Points
538 Posts
Re: i m not able to delete from database
Apr 24, 2012 07:15 AM|LINK
Try writing a stored procedure for deletion operation and call it in your code behind file
Smadhu
Member
511 Points
998 Posts
Re: i m not able to delete from database
Apr 24, 2012 07:44 AM|LINK
i hav wriiten n calling it too
Honnappa
Participant
1112 Points
534 Posts
Re: i m not able to delete from database
Apr 24, 2012 07:56 AM|LINK
Is it giving any error?
Post here or else
check permission for Imgaes/Resource/ folder (share this folder)
My Profile
amit.jain
Star
11225 Points
1815 Posts
Re: i m not able to delete from database
Apr 24, 2012 09:19 AM|LINK
refer http://www.csharpaspnetarticles.com/2012/03/delete-files-from-server-directory.html
amiT jaiN
ASP.NET C# VB Articles And Code Examples
sriramabi
Contributor
4351 Points
1277 Posts
Re: i m not able to delete from database
Apr 24, 2012 10:28 AM|LINK
remove this OnClientClick="javascript:return deleteItem(this.name);"
in u delete button then check and
pls give DeleteResource method full code...
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: i m not able to delete from database
Apr 27, 2012 01:51 AM|LINK
Hi,
Please use CommandName="Delete" instead of CommandName="DeleteResources".
If buttons within a GridView control invokes some of the built-in functionality of the control, you have to set the CommandName property of a button to one of the values: "Cancel","Delete","Edit","Page","Select","Sort","Update".
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand(v=vs.80).aspx
Feedback to us
Develop and promote your apps in Windows Store