RadDataForm
RadDataForm is designed to give your the freedom to specify predefined or customized type of layout for the items displayed in the control and in the same time gives you integrated paging and editing. You can embed various controls of your choice in RadDataForm's templates and model their appearance in a custom manner. Thanks to its innovative architecture RadDataForm is extremely fast and generates very little output.
Definition
Namespace:Telerik.Web.UI
Assembly:Telerik.Web.UI.dll
Syntax:
[ToolboxBitmap(typeof(RadDataForm), "Toolbox.Icons.DataForm.png")]
[ControlValueProperty("SelectedValue")]
[ClientScriptResource("Telerik.Web.UI.RadDataForm", "Telerik.Web.UI.DataForm.RadDataFormScripts.js")]
[TelerikToolboxCategory("Data")]
[EmbeddedSkin("DataForm", typeof(RadDataForm))]
[EmbeddedSkin("DataForm", "Default", typeof(RadDataForm))]
[RequiredCss("Telerik.Web.UI.Skins.Common.fonticons.css", RenderMode.Lightweight, typeof(RadDataForm))]
public class RadDataForm : RadCompositeDataBoundControl, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, INamingContainer, IScriptControl, IControlResolver, IPostBackDataHandler, ISkinnableControl, IControl, IFeatureGroup, IRadPageableItemContainer, IPostBackEventHandler, IPageableItemContainer
Inheritance: objectControlWebControlBaseDataBoundControlDataBoundControlCompositeDataBoundControlRadCompositeDataBoundControlRadDataForm...
Implements:
Inherited Members
Constructors
public RadDataForm()
Fields
public const string CancelCommandName = "Cancel"
public const string DeleteCommandName = "Delete"
public const string EditCommandName = "Edit"
public const string InitInsertCommandName = "InitInsert"
public const string PageCommandName = "Page"
public const string PerformInsertCommandName = "PerformInsert"
public const string RebindDataFormCommandName = "RebindDataForm"
public const string UpdateCommandName = "Update"
Properties
Gets or sets ID of RadClientDataSource control that to be used for client side binding
public string ClientDataSourceID { get; set; }
Gets a reference to the RadDataFormClientSettings object that allows you to set the properties of the client-side behavior and appearance in a Telerik RadDataForm control.
[PersistenceMode(PersistenceMode.InnerProperty)]
public RadDataFormClientSettings ClientSettings { get; }
Gets or sets a value that indicates whether empty string values ("")
are automatically converted to null values when the data field is
updated in the data source.
public virtual bool ConvertEmptyStringToNull { get; set; }
protected IEnumerable CurrentDataSource { get; set; }
Gets or sets a value indicating the index of the currently active page in case paging is enabled (AllowPaging is true).
[Bindable(true)]
[Browsable(false)]
public int CurrentPageIndex { get; set; }
The index of the currently active page in case paging is enabled.
Exceptions: ArgumentOutOfRangeExceptionvalue is out of range.
Gets or sets an array of data-field names that will be used to populate the DataKeyValues collection, when the RadDataFormcontrol is databinding.
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
[TypeConverter(typeof(RadDataFormStringArrayConverter))]
public virtual string[] DataKeyNames { get; set; }
Gets collection of data key values.
[Browsable(false)]
public virtual RadDataFormDataKeyArray DataKeyValues { get; }
The collection of data key values.
public int DataSourceCount { get; }
Gets or sets the name of the method to call in order to delete data
public string DeleteMethod { get; set; }
Gets the edit indexes which represent the indexes of the items that are currenly in edit mode.
[Browsable(false)]
public int EditIndex { get; set; }
The edit indexes which represent the indexes of the items that are currenly in edit mode.
Gets or sets the custom content for the item in edit mode.
[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TemplateContainer(typeof(RadDataFormDataItem), BindingDirection.TwoWay)]
public virtual ITemplate EditItemTemplate { get; set; }
An object that contains the custom content for the item in edit mode. The default is null, which indicates that this property is not set.
Gets or sets the Template that will be displayed if there are no records in the DataSource assigned.
[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TemplateContainer(typeof(RadDataForm))]
public virtual ITemplate EmptyDataTemplate { get; set; }
Gets the insert item of a RadDataForm control.
[Browsable(false)]
public RadDataFormInsertItem InsertItem { get; protected set; }
Gets or sets the location of the InsertItemTemplate template when it is rendered as part of the RadDataForm control.
public virtual RadDataFormInsertItemPosition InsertItemPosition { get; set; }
Gets or sets the custom content for an insert item in the RadDataForm control.
[TemplateContainer(typeof(RadDataFormDataItem), BindingDirection.TwoWay)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
public virtual ITemplate InsertItemTemplate { get; set; }
Gets or sets the name of the method to call in order to insert data
public string InsertMethod { get; set; }
protected bool IsBoundToIQueryableCollection { get; }
protected bool IsDataBinding { get; set; }
protected bool IsEnityDataSourceView { get; }
Gets or sets a value indicating if the RadDataForm is currently in insert mode.
[Browsable(false)]
public bool IsItemInserted { get; set; }
true, if the RadDataForm is currently in insert mode; otherwise, false.
The ItemInserted property indicates if the RadDataForm is currently in insert mode. After setting it you should call the Rebind() method.
protected bool IsLinqDataSourceView { get; }
protected bool IsModelValid { get; set; }
protected bool IsNeedDataSourceInProgress { get; set; }
protected bool IsOpenAccessDataSourceView { get; }
Gets or sets the ID for the item placeholder in a RadDataForm control.
public virtual string ItemPlaceholderID { get; set; }
The ID for the item placeholder in a RadDataForm control. The default is "itemPlaceholder".
Gets a collection of RadDataFormDataItem objects that represent the data items of the current page of data in a RadDataForm control.
[Browsable(false)]
public virtual RadDataFormDataItemCollection Items { get; }
Gets or sets the custom content for the data item in a RadDataForm control.
[TemplateContainer(typeof(RadDataFormDataItem), BindingDirection.TwoWay)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
public virtual ITemplate ItemTemplate { get; set; }
Gets or sets the custom content for the root container in a RadDataForm control.
[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TemplateContainer(typeof(RadDataForm))]
public virtual ITemplate LayoutTemplate { get; set; }
protected Control LayoutTemplateWrapper { get; set; }
Gets the number of pages required to display the records of the data source in a RadDataFormcontrol.
[Browsable(false)]
public virtual int PageCount { get; }
RenderWrapper property determines if the LayoutTemplate should be wrapped inside Div element with ID of the DataForm
public bool RenderWrapper { get; set; }
ResolvedDataSource
DataFormEnumerableBase
protected virtual DataFormEnumerableBase ResolvedDataSource { get; }
InvalidOperationException.
protected virtual int StartRowIndex { get; }
protected override bool SupportsRenderingMode { get; }
Overrides:
protected override HtmlTextWriterTag TagKey { get; }
Overrides:
Gets or sets the name of the method to call in order to update data
public string UpdateMethod { get; set; }
Gets a reference to the RadDataFormValidationSettings object that allows you to set the properties of the validate operation in a RadDataForm control.
[PersistenceMode(PersistenceMode.InnerProperty)]
public RadDataFormValidationSettings ValidationSettings { get; }
[Browsable(true)]
[Bindable(true)]
public virtual int VirtualItemCount { get; set; }
value is out of range.
Methods
protected virtual void AutoDataBind(RadDataFormRebindReason rebindReason)
Removes all edit items that belong to the RadDataForm instance.
public void ClearEditItems()
protected override void CreateChildControls()
Overrides:
When overridden in an abstract class, creates the control hierarchy that is used to render the composite data-bound control based on the values from the specified data source.
protected override int CreateChildControls(IEnumerable dataSource, bool dataBinding)
An IEnumerable that contains the values to bind to the control.
dataBindingbooltrue to indicate that the CreateChildControls(IEnumerable, bool) is called during data binding; otherwise, false.
Returns:The number of items created by the CreateChildControls(IEnumerable, bool) .
Exceptions: InvalidOperationExceptionThe RadDataForm control does not have an item placeholder specified.
Overrides:
protected virtual RadDataFormDataItem CreateDataItem(int displayIndex)
protected virtual int CreateDataItems(Control container, IEnumerable dataSource, bool dataBinding)
InvalidOperationException.
Creates a default DataSourceSelectArguments object used by the data-bound control if no arguments are specified.
protected override DataSourceSelectArguments CreateDataSourceSelectArguments()
A DataSourceSelectArguments initialized to Empty.
Overrides:
protected virtual RadDataFormItem CreateInsertItem()
The RadDataForm control does not have an InsertItemTemplate template specified.
public override void DataBind()
You should not call DataBind in NeedDataSource event handler. DataBind would take place automatically right after NeedDataSource handler finishes execution.
Overrides:
protected override void DescribeComponent(IScriptDescriptor descriptor)
Overrides:
protected virtual void EnsureLayoutTemplate()
The passed IDictionary object (like Hashtable for example) will be filled with the names/values of the corresponding RadDataFormDataItem's bound values and data-key values if included.
public virtual void ExtractValuesFromItem(IDictionary newValues, RadDataFormDataItem dataItem, bool includePrimaryKey)
dataItem is null.
newValues is null.
protected override IEnumerable<ScriptReference> GetScriptReferences()
Overrides:
Creates and instantiate layout template instance
protected virtual void InstantiateInsertItemTemplate(Control container)
Loads the client state data
protected override bool LoadClientState(Dictionary<string, object> clientState)
Overrides:
Restores control-state information from a previous page request that was saved by the SaveControlState() method.
Raises the ItemUpdating event.
protected virtual void OnItemCanceling(RadDataFormCommandEventArgs e)
Raises ItemCommand event
protected virtual void OnItemCommand(RadDataFormCommandEventArgs e)
Raises ItemCreated event
protected virtual void OnItemCreated(RadDataFormItemEventArgs e)
Raises ItemDataBound event
protected virtual void OnItemDataBound(RadDataFormItemEventArgs e)
Raises the ItemDeleted event.
protected virtual void OnItemDeleted(RadDataFormDeletedEventArgs e)
protected virtual void OnItemDeleting(RadDataFormCommandEventArgs e)
protected virtual void OnItemEditing(RadDataFormCommandEventArgs e)
protected virtual void OnItemInserted(RadDataFormInsertedEventArgs e)
protected virtual void OnItemInserting(RadDataFormCommandEventArgs e)
Raises the ItemUpdated event.
protected virtual void OnItemUpdated(RadDataFormUpdatedEventArgs e)
Raises the ItemUpdating event.
protected virtual void OnItemUpdating(RadDataFormCommandEventArgs e)
Raises NeedDataSource event
protected virtual void OnNeedDataSource(RadDataFormNeedDataSourceEventArgs e)
protected virtual void OnPageIndexChanged(RadDataFormPageChangedEventArgs e)
protected virtual void OnTotalRowCountAvailable(RadDataPagerPageEventArgs e)
Binds the data from the data source to the composite data-bound control.
protected override void PerformDataBinding(IEnumerable data)
An IEnumerable that contains the values to bind to the composite data-bound control.
Overrides:
Perform delete operation, using the DataSourceControl API. Please make sure you have specified the correct DataKeyNames for the RadDataForm.
public virtual void PerformDelete(RadDataFormDataItem editedItem, bool suppressRebind)
Perform asynchronous delete operation
public virtual void PerformDelete(RadDataFormDataItem editedItem)
Performs asynchronous insert operation, using the DataSourceControl API, then Rebinds. When the asynchronous operation calls back, RadDataForm will fire ItemInserted event.
public virtual void PerformInsert()
Insert item is available only when RadDataForm is in insert mode.
Performs asynchronous insert operation, using the DataSourceControl API, then Rebinds. When the asynchronous operation calls back, RadDataForm will fire ItemInserted event.
public virtual void PerformInsert(RadDataFormInsertItem insertItem, bool suppressRebind)
insertItem is null.
protected override void PerformSelect()
Overrides:
Perform asynchronous update operation, using the DataSource control API. Please make sure you have specified the correct DataKeyNames for the RadDataForm. When the asynchronous operation calls back, RadDataForm will fire ItemUpdated event. The boolean property defines if RadDataForm will Rebind() after the update.
public virtual void PerformUpdate(RadDataFormDataItem editedItem, bool suppressRebind)
editedItem is
null.
Perform asynchronous update operation, using the DataSource control API and the Rebind method. Please, make sure you have specified the correct DataKeyNames for the RadDataForm. When the asynchronous operation calls back, RadDataForm will fire ItemUpdated event.
public void PerformUpdate(RadDataFormDataItem editedItem)
protected void PopulateDataKeys(object dataItem)
There was a problem extracting DataKeyValues from the DataSource. Please ensure that DataKeyNames are specified correctly and all fields specified exist in the DataSource.
protected virtual void PrepareDataSource()
public virtual void RaisePostBackEvent(string eventArgument)
Implements:
Rebinds this instance and updates the RadDataForm.
public virtual void Rebind()
protected virtual void RemoveItems()
Renders the RadDataForm to the specified HTML writer.
protected override void Render(HtmlTextWriter writer)
The HtmlTextWriter object that receives the control content.
Overrides:
public override void RenderBeginTag(HtmlTextWriter writer)
Overrides:
protected override void RenderContents(HtmlTextWriter writer)
Overrides:
protected virtual Control RetrivePlaceHolderControl(Control container, string placeholderId)
The RadDataForm control does not have an item placeholder specified.
Saves any RadDataForm control state changes that have occurred since the time the page was posted back to the server.
protected override object SaveControlState()
Returns the RadDataForm's current state. If there is no state associated with the control, this method returns null.
Overrides:
protected virtual void SetPageProperties(int startRowIndex, int maximumRows, bool databind)
maximumRows is out of range.
startRowIndex is out of range.
Places the RadDataForm in insert mode, allowing user to insert a new data-item values.
public virtual void ShowInsertItem()
Places the RadDataForm in insert mode, allowing user to insert a new data-item values. The InsertItem created will be bound to values found in defaultValues dictionary;
public virtual void ShowInsertItem(IDictionary defaultValues)
values with which InsertItem will be populated
Places the RadDataForm in insert mode, allowing user to insert a new data-item values. The InsertItem created will be bound to the provided object;
public virtual void ShowInsertItem(object dataItem)
object to which InsertItem will be bound
Places the RadDataForm in insert mode, allowing user to insert a new data-item values. The InsertItem created will be bound to values found in defaultValues dictionary;
public virtual void ShowInsertItem(RadDataFormInsertItemPosition itemPosition, IDictionary defaultValues)
position at which the insertItem will be shown
defaultValuesIDictionaryvalues with which InsertItem will be populated
Places the RadDataForm in insert mode, allowing user to insert a new data-item values. The InsertItem created will be bound to the provided object;
public virtual void ShowInsertItem(RadDataFormInsertItemPosition itemPosition, object dataItem)
position at which the insertItem will be shown
dataItemobjectobject to which InsertItem will be bound
Places the RadDataForm in insert mode, allowing user to insert a new data-item values.
public virtual void ShowInsertItem(RadDataFormInsertItemPosition itemPosition)
protected override void TrackViewState()
Overrides:
Events
Occurs when the Cancel command is fired from any RadDataFormDataItem
public event EventHandler<RadDataFormCommandEventArgs> ItemCanceling
Raised when a button in a RadDataForm control is clicked.
public event EventHandler<RadDataFormCommandEventArgs> ItemCommand
Raised when RadDataFormItem is created
public event EventHandler<RadDataFormItemEventArgs> ItemCreated
Raised when RadDataFormItem is data bound
public event EventHandler<RadDataFormItemEventArgs> ItemDataBound
Occurs when a delete operation is requested, after the RadDataForm control deletes the item.
public event EventHandler<RadDataFormDeletedEventArgs> ItemDeleted
Occurs when a delete operation is requested, but before the RadDataForm control deletes the item.
public event EventHandler<RadDataFormCommandEventArgs> ItemDeleting
Occurs when an edit operation is requested, but before the RadDataForm item is put in edit mode
public event EventHandler<RadDataFormCommandEventArgs> ItemEditing
Occurs when an insert operation is requested, after the RadDataForm control has inserted the item in the data source.
public event EventHandler<RadDataFormInsertedEventArgs> ItemInserted
Occurs when an insert operation is requested, but before the RadDataForm control performs the insert.
public event EventHandler<RadDataFormCommandEventArgs> ItemInserting
Occurs when the Update command is fired from any RadDataFormDataItem
public event EventHandler<RadDataFormUpdatedEventArgs> ItemUpdated
Occurs when the Update command is fired from any RadDataFormDataItem
public event EventHandler<RadDataFormCommandEventArgs> ItemUpdating
Raised when LayoutTemplate is created
public event EventHandler<EventArgs> LayoutCreated
Raised when the RadDataForm is about to be bound and the data source must be assigned.
public event EventHandler<RadDataFormNeedDataSourceEventArgs> NeedDataSource
Fires when a paging action has been performed.
public event EventHandler<RadDataFormPageChangedEventArgs> PageIndexChanged