Skip to content

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.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/asp-net-web-forms-grid-use-listbox-to-save-and-restore-client-layout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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.

Topics

Resources

License

Stars

Watchers

Forks