aspnet-devexpress-dot-web-dot-aspxgridview-adf58674.md
Fires when the row focus changes.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public event EventHandler FocusedRowChanged
Public Event FocusedRowChanged As EventHandler
The FocusedRowChanged event's data class is EventArgs.
Set the ProcessFocusedRowChangedOnServer property to true to allow the control to fire the server-side FocusedRowChanged event.
The FocusedRowChanged event fires in the following cases:
If the ProcessFocusedRowChangedOnServer property is set to false, the control raises the client-side ASPxClientGridView.FocusedRowChanged event.
In the example below, the control raises the FocusedRowChanged event to save and restore the focused row index on the server side.
<dx:ASPxGridView ID="gridView" runat="server" AutoGenerateColumns="False"
OnDataBound="gridView_DataBound" OnFocusedRowChanged="gridView_FocusedRowChanged">
<SettingsBehavior AllowFocusedRow="true" ProcessFocusedRowChangedOnServer="true" />
<Columns>
<%--...--%>
</Columns>
</dx:ASPxGridView>
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"]);
}
Protected Sub gridView_FocusedRowChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim grid As ASPxGridView = TryCast(sender, ASPxGridView)
Response.Cookies(grid.ID)("FocudedIndex") = grid.FocusedRowIndex.ToString()
Response.Cookies(grid.ID).Expires = DateTime.Now.AddDays(1R)
End Sub
Protected Sub gridView_DataBound(ByVal sender As Object, ByVal e As EventArgs)
Dim grid As ASPxGridView = TryCast(sender, ASPxGridView)
If (Not IsPostBack) Then
If Request.Cookies(grid.ID) IsNot Nothing Then
grid.FocusedRowIndex = Convert.ToInt32(Request.Cookies(grid.ID)("FocudedIndex"))
End If
End If
End Sub
See Also