Delete row and delete from table

Hi

I need, after delete a grid row, execute a delete statment

Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand

Dim advogado As String
If (e.CommandName = "Apagar") Then
advogado = RTrim(e.CommandArgument.ToString)
Apaga_Processos(advogado)
End If
end sub

Private Sub Apaga_Processos(ByVal advogado As String)
Dim conn As SqlConnection
Dim comm As SqlCommand
Dim connectionString As String = ConfigurationManager.ConnectionStrings("mssql2.tuganet.com").ConnectionString
conn =
New SqlConnection(connectionString)
comm =
New SqlCommand("delete from processos_adv where advogado=@advogado", conn)
comm.Parameters.Add(
"@advogado", System.Data.SqlDbType.NVarChar)
comm.Parameters(
"@advogado").Value = RTrim(advogado)
conn.Open()
comm.ExecuteNonQuery()
conn.Close()
End Sub

 In my gridview i have the code

<ItemTemplate>

<asp:Button ID="Button2" runat="server" CausesValidation="false"

CommandName="Delete" CommandArgument='<%# Bind("Nome")%>' Text="Apagar" onClientClick="javascript:return window.confirm('Are you sure?');" />

</ItemTemplate>

Why  Apaga_Processos  is not executed?

Thank you

 


Mario Lopes
0
mariolopes
5/14/2008 9:56:27 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
737 Views

Similar Articles

[PageSpeed] 22

Change your code to this below

Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand

Dim advogado As String
If (e.CommandName = "Delete") Then
advogado = RTrim(e.CommandArgument.ToString)
Apaga_Processos(advogado)
End If
end sub

Your Command name is Delete and not Apagar 

 


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
5/14/2008 9:59:09 PM
Reply:

Similar Artilces:

adding / deleting table rows, and accessing controls within added rows
Hi everyone,I would like to know what is a good and simple way to achieve this using asp.net.  Basically i would like the ability to add and delete rows, preferably table rows.  Against each row is its delete button, hitting it will delete the corresponding row.  There is only 1 Add button to add a new row.  In each row, there are say 2 textboxes.  When i hit, say a calculate button, i wish to be able to access all the available textboxes in all the available rows in the event handler, and say just output a sum.If GridView is suggested, could you please explain why i...

How to delete controls in GridView when the delete button in a row is clicked
Hi,   I am having issues with my gridview.....i added 2 dropdown and 2 compare validators....whenever i delete a row though......the dropdown and compare validators are becoming null........thus when i click a button, it is still validating.............anyway to delete this when i click the delete button or even handle?   Please help.  ...

Deletes are not being deleted.
Using ASA 7.03 I am having a problem in deleting field service orders that have been completed. Just getting started with sync so I am probably making a dumb mistake or just leaving out a step. The download_delete_cursor script is: Select ordernumber from ServiceOrderEntryMaster where Tech = ? and Order_Complete = 'Y' This based on the verbose reply from the MobiLink Synchronization server is picking the correct work order ( number 326 ) and showing a Delete Row line in the log. But the work order is not being deleted on the remote side. What could I be doing wron...

Deleting rows from one table based upon rows in another table
I need to delete rows from table1 based on rows in table2. table1 has 1.5 million rows from which I need to delete 20,000 existing in table2. The table structures are the same and I must exactly match 10 (of the 15) columns in the tables. I also need to limit the number of rows being worked on, in a single transaction, to 500 or so. Hi Mike, try the following: set rowcount 500 DELETE table1 from table1 t1,table2 t2 where t1.col1=t2.col1 and t1.col2=t2.col2 and t1.col3=t2.col3 and ........ t1.col10=t2.col10 HTH. Regards P:S You must re-execute the DML statement above 40 time...

Delete Row Method (getting the primarykey of row being deleted)
Hello friends,I'd like to retrieve the primary key of the row being deleted so i can use it as a parameter in my stored procedure: Here's how far i have come with my code. I need help with line 6.Thanks in advance :)  1 Protected Sub DependentsObjectDataSource_Deleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles DependentsObjectDataSource.Deleting2 3 'get value of deleting depednent id4 'Delete (Unenroll) all benefits dependent enrolled in before attempting to delete dependen...

Deleting the master table withour deleting the child tables
Hi i have to delete the master table data without deleting the child table records,is there any solution for this,  parent table has relation with the child table. regards vinod.t.vSoftware EngineerUshustechTechnoparkTrivandrum India You need to temporarily disable constraints on the table. Disable constraints: ALTER TABLE MyTable NOCHECK CONSTRAINT ALL Enable constraints: ALTER TABLE MyTable CHECK CONSTRAINT ALL    If this post was useful to you, please mark it as answer. Thank you! Thanks johram i can try this solution, this is usefullSoftware Enginee...

Insert/Delete/Delete all rows
Hi Neither in data window painter nor in data base painter I can Insert, Delete and Delete all Rows for a table. These Items are in both painters gray and can,t been selected. Is something wrong on my installation of PB? PB 7.02 (Build 8030) Can someone help me? Thanks Taghi Pouradjam Does your table have a primary key defined? -- <hopethishelps /> Roy Kiesler [TeamSybase] mySybase -- http://my.sybase.com "Taghi Pouradjam" <pouradjam@oasys.de> wrote in message news:OzIH97fiAHA.128@forums.sybase.com... > Hi > > Neither in data wi...

delete row or delete all in Gridview?
Hi there, I have a Gridview that bind the data from the .mdb  and I want to have 2 delete buttions, one is delete a row and the other one is delete all from the database.  How do I do it in code behind in c#?  thanks a lot row delete  (temp call rowDel) all delete (temp call allDel) with rowDel: i think you should bound one column in gridview  (or datagrid)<asp:ButtonColumn... and bout allDel: i think you should use a button distinct with gridview.Becoz your required is not complex , when allDel be push you don't care...

Showing table columns from multiple tables in Formview, but insert/update/delete rows of Master table
I have a page on which I have GridView and FomView control. On selection of a row in GridView the row gets displayed in the Item template of the FormVIew. The values are the result of inner join from multiple tables i.e. table Stock,Product and Workshop.  Please let me know how I could insert/update/delete data for the base table i.e. Stock table, but be able to see the column values from the associated tables on the Itemtemplate,Edittemplate and Inserttemplate of the FormView. Thanks,Anita Hi:   Take a look at this tutorial. It's for DetailsView and same ...

Need to delete rows from table if checkboxes are checked for row
Hello. I have a linkbutton that will delete individual rows from my gridview and update the database, however, I want to be able to make multiple selections via the checkboxes which appear on each row, and click just one button to delete all the checked rows. The following is from my aspx page:  <div style="float: right;"> <asp:Button ID="btnLinkBack" runat="server" Text="Check Backlinks" /> <asp:Button ID="btnApprove" runat="server" Text="Unhide" /> ...

How to add a footer row to a table after deleting all footer rows
I'm sure this is a very easy thing to do, but I can't figure out how to do it. I have a table, and I deleted all the footer rows.  Now I would like to add one footer row.  How do I do that? If I right-click on the detail row and select Insert Row Below, it is, of course, another detail row. I'm stumped -- thanks for any help you can give!Cynthia Do you have groups in your table?  You should be able to right click on any table row and toggle the corresponding menu item to show the table header, details or footer.  It is in the right click menu includ...

Deleting a row from a table
Hello, I inserted a table into my webpage during design time.  Isn' t there a way to delete a row from the table during design time? Without having to draw the entire table again?  Thanks.  Is your table databound or did you populate the data yourself? I believe tables have a rows.remove method. which you pass a row object or you can use the rows.removeat which take an integer value for the row to removeRemeber to mark as Answer if someone's answer helped you. Just switch to source and delete from <tr> to </tr>, the open tag to the close tag of the ro...

Deleting rows from a table
I am using Thunderbird v 2 in Windows 2000. I send out a newsletter to a boating organization and include a table of upcoming rendezvous. For next month I want to remove the rendezvous for February. I want to remove the data but also the row. When I go into table configuration and reduce the number of rows it lops one off of the bottom. I don't see how to get rid of the empty row on top. Please advise. Thank you, The date and time was Thursday, February 12, 2009 9:44:23 PM, and on a whim, Gualtier Malde pounded out on the keyboard: > I am using Thunderbird v 2 ...

Delete a row in my table
Hi, I have this code in my asp file:1 <asp:GridView ID="GridView" runat="server" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="AccessDataSource1"> 2 <FooterStyle BackColor="#CCCCCC" /> 3 <Columns> 4 <asp:BoundField DataField="ID" HeaderText="ID" Ins...

Web resources about - Delete row and delete from table - asp.net.presentation-controls

Delete key - Wikipedia, the free encyclopedia
, known less ambiguously as forward delete ) discards the character ahead of the cursor 's position, moving all following characters one position ...

Facebook Fined $77K by Argentine Court for Failing to Delete Alleged Defamatory Groups
... mess in Argentina , as PanAm Post reported that a Rosario court ordered the social network to pay compensation of $77,000 for failing to delete ...

Facebook adds search history to Activity Log so users can delete queries
... in users’ Activity Logs. The feature will be rolled out to all users in the next few weeks. The feature allows for users to view and delete ...

Tweets MPs Delete (@deletedbyMPs) on Twitter
Sign in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Tweets MPs Delete @ deletedbyMPs ...

Oren Jacob's answer to Pixar Animation Studios: Did Pixar accidentally delete Toy Story 2 during production ...
Oren Jacob's answer: Hi everyone, I'm the Oren Jacob in the video. Hopefully I can offer some first person color commentary about the video above ...

Tweeticide - Delete All of Your Twitter Tweets at Once! on the App Store on iTunes
Get Tweeticide - Delete All of Your Twitter Tweets at Once! on the App Store. See screenshots and ratings, and read customer reviews.

Delete, and I mean it! - Flickr - Photo Sharing!
I bought a new keyboard at work because I spilled cereal on the previous one and some of the keys stopped working. The new one has a giant delete ...

Viber now lets you attach files, delete messages and more
... and public chat forwarding in late September , the app keeps growing. In an update today, Nov. 24, Viber users can now attach files, delete ...

Anonymous aims to delete the Islamic State 'virus' from the web, and wants your help
... spread their ideals of terror among the young and impressionable. The aim of #OpISIS is to shut down these channels where possible, and "delete ...

Man sues Apple after retail employee deletes years worth of photos
Deric White, a 68 year-old man from the UK, is suing Apple for approximately $7,500 after an Apple employee at the company's Regent Street store ...

Resources last updated: 12/21/2015 12:01:49 PM