Imports Telerik.WebControls
Imports System.Data.OleDb
Imports System.Web.UI.WebControls
Imports System.Data


Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub RadMenu1_ItemClick(ByVal sender As Object, ByVal e As RadMenuEventArgs)
        Dim RadGridClickedRowIndex As Integer
        RadGridClickedRowIndex = Convert.ToInt32(Request.Form("RadGridClickedRowIndex"))
        Select Case e.Item.Text
            Case "Edit"
                RadGrid1.Items(RadGridClickedRowIndex).Edit = True
                RadGrid1.Rebind()
            Case "Add"
                RadGrid1.MasterTableView.IsItemInserted = True
                RadGrid1.Rebind()
            Case "Delete"
                RadGrid1.MasterTableView.PerformDelete(CType(RadGrid1.Items(RadGridClickedRowIndex), GridEditableItem))
        End Select
    End Sub

    Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As EventArgs) Handles RadGrid1.PreRender
        If RadGrid1.EditIndexes.Count > 0 OrElse RadGrid1.MasterTableView.IsItemInserted Then
            CType(RadGrid1.MasterTableView.GetColumn("EditCommandColumn"), GridColumn).Visible = True
        Else
            CType(RadGrid1.MasterTableView.GetColumn("EditCommandColumn"), GridColumn).Visible = False
        End If
    End Sub


End Class

