Imports System.Data.SqlClient
Public Class listview
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Response.Write("value loop " & gvwExample.PageIndex & "
")
        
        Dim cmd As SqlCommand = New SqlCommand("SELECT  UserName,pass_word,ApplicantName,FatherName FROM userinfo", New SqlConnection(" Server=vu-it-wqs-pc\sqlexpress;Database=Test;Uid=sa;Pwd=123;"))
        Try
            Dim adp As New SqlDataAdapter(cmd)
            cmd.Connection.Open()
            Dim ds As New DataSet()
            adp.Fill(ds)
            gvwExample.DataSource = ds
            cmd.ExecuteReader()

            gvwExample.DataBind()
            adp.Dispose()
            ds.Dispose()

            cmd.Connection.Dispose()

        Catch ex As Exception
            lblStatus.Text = ex.Message
       


        End Try
    End Sub
    Protected Sub OnPaging(ByVal sender As Object, ByVal e As GridViewPageEventArgs) Handles gvwExample.PageIndexChanging
        Try
            gvwExample.PageIndex = e.NewPageIndex
            gvwExample.AllowPaging = True

            gvwExample.DataBind()
        Catch ex As Exception
            lblStatus.Text = ex.Message
        End Try
    End Sub

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)
        Response.Redirect("DBform.aspx")
        lblStatus.Text = "dddd"
        If Not (IsPostBack) Then

            lblStatus.Text = "dddd1"
            If (e.CommandName = "Delete") Then
                ' Retrieve the row index stored in the CommandArgument property.
                Dim index As Integer = Convert.ToInt32(e.CommandArgument)
                lblStatus.Text = "dddd2"
                ' Retrieve the row that contains the button 
                ' from the Rows collection.
                Dim row As GridViewRow = gvwExample.Rows(index)
                Response.Write("value loop " + index + "
")
                ' Add code here to add the item to the shopping cart.

            End If
        End If
    End Sub



    'Protected Sub gvwExample_SelectedIndexChanged(sender As Object, e As EventArgs) Handles gvwExample.SelectedIndexChanged
    '    If Not (IsPostBack) Then


    '        'If (e.CommandName = "Delete") Then
    '        '    ' Retrieve the row index stored in the CommandArgument property.
    '        '    Dim index As Integer = Convert.ToInt32(e.CommandArgument)

    '        '    ' Retrieve the row that contains the button 
    '        '    ' from the Rows collection.
    '        '    Dim row As GridViewRow = gvwExample.Rows(index)
    '        Response.Write("value loop 55" & gvwExample.PageIndex & "
")
    '        ' Add code here to add the item to the shopping cart.

    '        'End If
    '    End If
    'End Sub
End Class






aspx code


 <%@ Page Language="vb" AutoEventWireup="false"  CodeBehind="listview.aspx.vb" Inherits="WebAppFramework20.listview" %>


   
   
  
   
   
             
             
               
               
               
           
       
                    HTML5 Icon
                    HTML5 Icon
                    HTML5 Icon
       
             
             
             
               
                
           
       
                    aaaa
               
                    aaaab
               
                    aaaac
               
       

       
             CellPadding="4" EnableModelValidation="True" ForeColor="Black"
             GridLines="Horizontal" AutoGenerateColumns="False" BackColor="White"
             BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" Width="666px"
             PageSize="5"  AllowPaging="True" OnPageIndexChanging="OnPaging">
           
    

   
   
            DataNavigateUrlFormatString="DBform.aspx?ID={0}" />      
   
 
   
         CommandName = "Delete"
    CommandArgument = "<%# CType(Container,GridViewRow).RowIndex %>"
      Text="Delete" />
   
              
               
           
           
           
           
           
                
           
             

   




i found this error when row command button event fire