To implement such a functionality, you first need to set up the ASPxDataView so that it shows only one record at a time. To do so, set the Rows and Columns count to 1. Then place ASPxFormLayout into ItemTemplate and handle its DataBinding event to bind it to the ASPxDataView's DataItem. To update edited records, place the ASPxButton under the ASPxFormLayout. On its click, iterate through UpdateParameters of the SqlDataSource and set its values to those from the ASPxFormLayout.
Question Comments
Added By: Dhaval.Shah at: 12/8/2015 7:00:18 PM
An alternate way to achieve the same could be:
1. Have each item in the ASPxFormLayout bound to data.
Example:
<dx:LayoutItem Caption="Title" FieldName="Title">
...
2. Declare the Dataview's PageIndexChanged event in which we will assign the datasource to the form layout control (globally)
Example:
protected void DataView_PageIndexChanged(object sender, EventArgs e)
{
ASPxFormLayout flView = LoadcaseDataView.FindItemControl("ASPxFormLayout1", DataView.VisibleItems[0]) as ASPxFormLayout;
flView.DataSource = DataView.VisibleItems[0].DataItem;
flView.DataBind();
}
This will achieve the same functionality I believe. Note that there is only 1 record per "view" (1 column, 1 row) which makes this work, as there is only one "VisibleItem" of the dataview per page.
So, when the page index has changed, the VisibleItems[0].DataItem reflects the current record correctly.
This is just for navigation and rest of the functionality mentioned here is still valid.
I do stand to be corrected however.
Hello,
In this example, you do not need to handle the PageIndexChanged event. When an active page is changed, the ASPxFormLayout1_DataBinding event is raised. So, you just need to correctly specify ASPxFormLayout's data source.