New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Population/Data Editing with XmlDataSource Control

RadGrid can use the XmlDataSource control to generate its content from XML and perform data editing operations. Note that automatic update, insert, and delete operations, which work with other data source controls such as AccessDataSource, SqlDataSource, and ObjectDataSource, do not work when using XmlDataSource. If you want to enable editing, you must write custom code to modify data in the XML source file.

The following restrictions apply to editing XML data when using XmlDataSource control:

  • The XML data must be loaded from an XML file specified with the DataFile property of the XmlDataSource control, and not from an xml string specified in the Data property.

  • No XSLT transformation can be specified in the Transform or TransformFile properties of the XmlDataSource control.

  • The Save method does not handle concurrent save operations on unique requests. If more than one user is editing an XML file using the XmlDataSource control, there is no guarantee that all users are operating with the same data and that one user will not overwrite changes from another user. It is also possible for a save operation to fail because another user is writing to the XML file and has an exclusive lock on the file.

ASP.NET
<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" Skin="Web20" Width="95%" DataSourceID="XmlDataSource1"
  OnInsertCommand="RadGrid1_InsertCommand" OnUpdateCommand="RadGrid1_UpdateCommand"
  OnDeleteCommand="RadGrid1_DeleteCommand">
  <MasterTableView AutoGenerateColumns="false" DataKeyNames="CustomerID" CommandItemDisplay="Top">
    <Columns>
      <telerik:GridEditCommandColumn />
      <telerik:GridBoundColumn UniqueName="CompanyName" DataField="CompanyName" HeaderText="CompanyName">
      </telerik:GridBoundColumn>
      <telerik:GridBoundColumn UniqueName="ContactName" DataField="ContactName" HeaderText="ContactName">
      </telerik:GridBoundColumn>
      <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
      </telerik:GridButtonColumn>
    </Columns>
  </MasterTableView></telerik:RadGrid>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/Xml/XmlDataSourceExampleTemp.xml">
</asp:XmlDataSource>

For a live example of a RadGrid that supports editing when bound to XmlDataSource, see Editing XML using XmlDataSource.

Not finding the help you need?
Contact Support