Thursday, November 29, 2012

ASPX GridView Edit, Cancel Edit, Updating with VB


Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView4.RowEditing
        GridView1.EditIndex = e.NewEditIndex
        bindGridView1()
End Sub


 Protected Sub GridView1_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GridView4.RowCancelingEdit
        GridView1.EditIndex = -1
        bindGridView1()
 End Sub


Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView4.RowUpdating

' do something ~~like update DB or insert into DB
 GridView1.EditIndex = -1
 bindGridView4()

End Sub

   




Sub bindGridView1()
        Dim SQL As String=session("orignal_sql_string")
        If SortField.ToString() <> "" Then
            SQL = SQL & "order by " & SortField.ToString()
        Else
            ' SQL = SQL & "order by form_idx ASC "
        End If
        Try
            Dim ds As DataSet = GetTableData(SQL)
            GridView1.DataSource = ds
            GridView1.DataBind()
           Catch ex As Exception
            '  lbErrorMessage.Text = ex.Message
        End Try
End Sub


No comments:

Post a Comment