New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Firing Command Events from Code
In some specific cases you may want to raise command events (like Edit/Update/Delete/Sort/Page/etc.) in code rather than clicking buttons which are placed inside RadListView. For such type of situations Telerik RadListView exposes the FireCommandEvent(eventName, eventArgs) method which can be called from all RadListView items that inherit from RadListViewItem class.
The table below explains the parameters which you can pass to that method to fire corresponding commands:
RadListView command | Type of item used to invoke the method | FireCommandEvent syntax | eventArgs details |
---|---|---|---|
RadListViewEditableItem, RadListViewDataItem | FireCommandEvent("Edit", RadListViewCommandEventArgs) | Required but not used Example: FireCommandEvent("Edit", String.Empty) | |
Update | RadListViewEditableItem, RadListViewDataItem | FireCommandEvent("Update", RadListViewCommandEventArgs) | Required but not used Example: FireCommandEvent("Update", String.Empty) |
Delete | RadListViewDataItem | FireCommandEvent("Delete", RadListViewCommandEventArgs) | Required but not used FireCommandEvent("Delete", String.Empty) |
InitInsert | RadListViewEditableItem, RadListViewDataItem,RadListViewItem | FireCommandEvent("InitInsert", RadListViewCommandEventArgs) | Required but not used FireCommandEvent("InitInsert", String.Empty) |
PerformInsert | RadListViewEditableItem,RadListViewDataItem,RadlListViewInsertItem | FireCommandEvent("PerformInsert", RadListViewCommandEventArgs) | Required but not used Example: FireCommandEvent("PerformInsert", String.Empty) |
Cancel | RadListViewEditableItem,RadListViewDataItem | FireCommandEvent("Cancel", RadListViewCommandEventArgs) | Required but not used Example: FireCommandEvent("Cancel", String.Empty) |
Page | RadListViewItem | FireCommandEvent("Page", RadListViewPageChangedEventArgs) | string argument: "First", "Next", "Prev", "Last", numeric values as string presentation Example: FireCommandEvent("Page", "Next") |
Sort | RadListViewItem | FireCommandEvent("Sort", RadListViewSortEventArgs) | string argument: fieldName (mandatory), sortOrder (optional) Example: FireCommandEvent("Sort", "ContactName") |
Select | RadListViewDataItem | FireCommandEvent("Select", RadListViewSelectCommandEventArgs) | Required but not used Example: FireCommandEvent("Select", String.Empty) |
Deselect | RadListViewDataItem | FireCommandEvent("Deselect", RadListViewDeselectCommandEventArgs) | Required but not used Example:FireCommandEvent("Deselect", String.Empty) |
Rebind | RadListViewItem | FireCommandEvent("Rebind", RadListViewCommandEventArgs) | Required but not used Example: FireCommandEvent("Rebind", String.Empty) |
ChangePageSize | RadListViewItem | FireCommandEvent("ChangePageSize", RadListViewPageSizeChangedEventArgs) | string argument: Example: FireCommandEvent("ChangePageSize", 15) |