473,411 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Gridview on Delete button and Sorting

5
Hi, I have a problem with my gridview for the deleting and sorting part.
When I try to delete after I sort, it did not delete the correct items that I wanted it to delete.
Can someone help me on this?

Expand|Select|Wrap|Line Numbers
  1. Protected Sub LinkButton1_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
  2.         If e.CommandName = "SortByName" Then
  3.             If Sort = "ASC" Then
  4.                 Sort = "DESC"
  5.             Else
  6.                 Sort = "ASC"
  7.             End If
  8.  
  9.             DataSet.Tables(0).DefaultView.Sort = "Name " & Sort
  10.             Gridview.DataSource = DataSet.Tables(0).DefaultView
  11.             Gridview.DataBind()
  12.  
  13.         End If
  14. End Sub
  15.  
  16. Protected Sub Gridview_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles Gridview.RowDeleting
  17.     Dim name As String = CType(Gridview.Rows(e.RowIndex).FindControl("Label1"), Label).Text
  18.     database.OpenConn()
  19.     Dim strsql As String = "Delete from table where Name = '" & name & "'"
  20.     database.ExecuteUpdate(strsql)
  21.     database.CloseConn()
  22.  
  23. End Sub
  24.  
Apr 25 '13 #1
0 768

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
0
by: hougie40 | last post by:
I have a simple Gridview sample that I threw together. On my localhost the delete button works but on our dev server it just refreshes the page but does not remove the record. Code is...
3
by: JN | last post by:
I am using the sqldatasource to populate a gridview and I have a pop up that fires when the item_deleting event is triggered. Now in the popup, if the user clicks cancel, i dont want the delete...
0
by: weiwei | last post by:
Hi, I have create a data grid view with delete button in VS 2005. so far I have able to display the data from database, howvever, there are two issues 1)I do not know how to call the delete...
1
by: keithb | last post by:
I have a GridView control that has a delete button (hyperlink) in one column. The datasource table contains a column that has a true/false indicator showing whether or not the record can be...
1
by: JasonK | last post by:
I would like to move the Delete button such that it displays one time in the footer row, rather than on every row. I've seen lots of questions asked on the subject around the net, but no answer...
3
by: tarscher | last post by:
Hi all, I have a grid that contains 7 columns from 3 tables (3 unique keys, 4 normal fields). I show this 7 columns on the gridview. I now want to add edit and delete functionality. This should...
3
by: pargat.singh | last post by:
I want to add delete button to grid view and pass all the clicked row parameters. Can someone please tell me how can i do this? Below are my codes. Thanks in advance. <asp:GridView...
0
by: Eraser | last post by:
Hi to all .NET guru guys... I have a problem in my delete button inside gridview. How to avoid postback on when i select cancel on confirmation message? But postback is okay on Ok confirmation....
0
by: gamesforums | last post by:
Hi! I need to add a delete button to my GridView and wire up the onclick event to a sub in my vb.code. The grid itself are created in the codebehing - I have no aspx file that I can use for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.