Я использую этот код для удаления строк в gridview.Должно быть так: «пока он удалил строку, возьмите строку № 5 с серийным номером 5, поле с последовательным номером строки 6 должно стать 5. означает уменьшение серийного номера после удаления одной строки».но это не происходит, пока я удаляю строку № 5 с серийным номером 5, строка № 6 остается прежней.
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
For Each control As Control In e.Row.Cells(0).Controls
Dim DeleteButton As LinkButton = TryCast(control, LinkButton)
If DeleteButton IsNot Nothing AndAlso DeleteButton.Text = "Delete" Then
DeleteButton.OnClientClick = "return(confirm('Are you sure you want to delete this record?'))"
End If
Next
End Sub
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
If e.CommandName = "Delete" Then
' get the categoryID of the clicked row
Dim Serial As Integer = Convert.ToInt32(e.CommandArgument)
' Delete the record
Dim mycommand As New SqlCommand("DELETE FROM target WHERE SlNo = '" & Serial & "'", con)
con.Open()
mycommand.ExecuteNonQuery()
con.Close()
bindphoto2()
Label1.Text = "File has been deleted succefully"
End If
End Sub
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs)
Dim Serial As Integer = CInt(GridView1.DataKeys(e.RowIndex).Value)
Dim mycommand As New SqlCommand("DELETE FROM target WHERE SlNo = '" & Serial & "'", con)
con.Open()
mycommand.ExecuteNonQuery()
con.Close()