Share via


DataRepeaterAddRemoveItemsCancelEventArgs.ItemIndex Property

Gets the index of the item that is being deleted.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaration
Public ReadOnly Property ItemIndex As Integer
public int ItemIndex { get; }
public:
property int ItemIndex {
    int get ();
}
member ItemIndex : int
function get ItemIndex () : int

Property Value

Type: Int32
The index of the item.

Remarks

The DeletingItems and UserDeletingItems events occur when a request is made to delete a DataRepeaterItem from a DataRepeater control.

You can override the deletion by setting the cancel parameter of the DataRepeaterAddRemoveItemsCancelEventArgs to True.

Examples

The following example demonstrates how to cancel a deletion in the DeletingItems event handler.

Private Sub DataRepeater1_DeletingItems(
    ByVal sender As Object, 
    ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterAddRemoveItemsCancelEventArgs
  ) Handles DataRepeater1.DeletingItems

    ' Check whether the user is a supervisor. 
    If My.User.IsInRole("Supervisor") = False Then 
        ' Cancel the deletion and display a message.
        e.Cancel = True
        MsgBox("You are not authorized to delete.")
    End If 
End Sub
private void DataRepeater1_DeletingItems(object sender, 
    Microsoft.VisualBasic.PowerPacks.DataRepeaterAddRemoveItemsCancelEventArgs e)
{
    // Check whether the user is a supervisor.

    ClientRolePrincipal rolePrincipal =
        System.Threading.Thread.CurrentPrincipal
        as ClientRolePrincipal;

    if (rolePrincipal.IsInRole("supervisor") == false)
    {
        e.Cancel = true;
        MessageBox.Show("You are not authorized to delete.");
    }
}   

.NET Framework Security

See Also

Reference

DataRepeaterAddRemoveItemsCancelEventArgs Class

Microsoft.VisualBasic.PowerPacks Namespace

DeletingItems

UserDeletingItems

Other Resources

Introduction to the DataRepeater Control (Visual Studio)

How to: Disable Adding and Deleting DataRepeater Items (Visual Studio)