ASPxGridView.FocusedRowChanged Event
Fires after the focused row has been changed.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v21.2.dll
NuGet Package: DevExpress.Web
Declaration
Event Data
The FocusedRowChanged event's data class is EventArgs.
Remarks
The FocusedRowChanged event is raised when an end-user moves focus from one row to another or after the ASPxGridView.FocusedRowIndex property’s value has been changed in code.
If the ASPxGridViewBehaviorSettings.ProcessFocusedRowChangedOnServer property is set to false, the ASPxClientGridView.FocusedRowChanged event is handled on the client side without a callback to the server. Setting this property to true indicates that the final processing of the event should be performed on the server side, and so a round trip to the server is required. During such a round trip, the corresponding server-side FocusedRowChanged event is fired, which if handled, allows any desired server-side action to be performed.
Refer to the following section for more information: Focused Row.
Example
The example below demonstrates how to save a focused row index in cookies:
<dx:ASPxGridView ID="gridView" runat="server" AutoGenerateColumns="False" DataSourceID="ads"
KeyFieldName="CategoryID" ClientInstanceName="gridView" OnDataBound="gridView_DataBound" OnFocusedRowChanged="gridView_FocusedRowChanged">
<SettingsBehavior AllowFocusedRow="true" ProcessFocusedRowChangedOnServer="true" />
<Columns>
<dx:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" VisibleIndex="0">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="2">
</dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>
<asp:AccessDataSource ID="ads" runat="server" DataFile="~/App_Data/nwind.mdb" SelectCommand="SELECT * FROM [Categories]"></asp:AccessDataSource>
protected void gridView_FocusedRowChanged(object sender, EventArgs e) {
ASPxGridView grid = sender as ASPxGridView;
Response.Cookies[grid.ID]["FocudedIndex"] = grid.FocusedRowIndex.ToString();
Response.Cookies[grid.ID].Expires = DateTime.Now.AddDays(1d);
}
protected void gridView_DataBound(object sender, EventArgs e) {
ASPxGridView grid = sender as ASPxGridView;
if(!IsPostBack)
if (Request.Cookies[grid.ID] != null)
grid.FocusedRowIndex =Convert.ToInt32(Request.Cookies[grid.ID]["FocudedIndex"]);
}