RadGrid for ASP.NET AJAX

RadControls for ASP.NET AJAX

In some particular cases you may want to present the WebUserControl edit form of your grid instance in readonly mode - for example if you would like to acquaint the user with the structure of this edit form without giving him the option to actually edit the data in the grid. This scenario is useful when setting permissions for the users on a regular basis - some of them can be allowed to edit data (through EditCommandColumn) and for the rest you can display a preview column.

The "preview" functionality for user control edit form is easily achievable. To support readonly mode for your user control edit form please follow the steps depicted below :

  1. Add GridButtonColumn to your grid instance with CommandName = "Preview".

    CopyASPX
      <MasterTableView CommandItemDisplay="Top" GridLines="None">
        <EditFormSettings UserControlName="EmployeeDetailsVB.ascx" EditFormType="WebUserControl">
            <EditColumn UniqueName="EditCommandColumn1">
            </EditColumn>
        </EditFormSettings>
        <Columns>
            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
            </telerik:GridEditCommandColumn>
            <telerik:GridButtonColumn CommandName="Preview" Text="Preview" UniqueName="Preview">
            </telerik:GridButtonColumn>
            <telerik:GridBoundColumn HeaderText="TOC" DataField="TitleOfCourtesy" UniqueName="TitleOfCourtesy">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="FirstName" DataField="FirstName" UniqueName="FirstName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="LastName" DataField="LastName" UniqueName="LastName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="Hire Date" DataField="HireDate" UniqueName="HireDate">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="Title" DataField="Title" UniqueName="Title">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
  2. Handle the Preview command execution in your ItemCommand event handler and call the SetPreviewMode() method to force the user control in preview mode:

  3. In the code-behind of the user control disable all controls which reside in the edit form (except the cancel button) and change the cancel button text to Close.