Skip to content

Latest commit

 

History

History
49 lines (38 loc) · 2.91 KB

File metadata and controls

49 lines (38 loc) · 2.91 KB

Grid View for ASP.NET Web Forms - How to use a list box editor to save and restore client layout

This example demonstrates how to handle the grid's ClientLayout event to save and restore the grid's client layout. The modified layouts are added to a list box editor.

Save and resore client layout

Overview

The main idea is to handle the grid's server-side ClientLayout event to save the modified client layout to a Dictionary<string, string> and add the layout to a list box editor. Then, a user can choose the layout from the editor and apply it to the grid.

protected void Grid_ClientLayout(object sender, ASPxClientLayoutArgs e) {
    if (e.LayoutMode == ClientLayoutMode.Saving && isSaveLayout) {
        string key = DateTime.Now.ToString();
        string layout = e.LayoutData;
        Dictionary<string, string> dictionary = Session["layout"] as Dictionary<string, string>;
        if (!dictionary.ContainsValue(layout)) {
            ListBox.Items.Add(key, layout);
            dictionary[key] = layout;
        }
        else {
            Session["selectedLayout"] = layout;
        }
        Session["layout"] = dictionary;
    }
}

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)