This is a migrated thread and some comments may be shown as answers.

Use UserControl Editor as Viewer

2 Answers 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 30 Apr 2010, 05:21 PM
Is it possible to use a UserControl I have set up as a editor as a detail viewer as well?  I know I can accomplish this same thing using a NestedViewTemplate but it seems like it would make more sense to simply add a third mode to my editor which already does Insert and Update.

2 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 04 May 2010, 11:52 AM
Hi Andrew,

You can use WebUserControl edit mode for RadGrid, where you can replace the user control dynamically based on your command. For example, if you have a button column firing a custom command (say "View"), you can handle the command in ItemCommand event and put the item in edit mode with the replaced edit form:

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
    if (e.CommandName == "View")
    {
        e.Item.OwnerTableView.EditFormSettings.UserControlName = "MyViewControl.ascx";
        e.Item.Edit = true;
        e.Item.OwnerTableView.Rebind();
    }
}

In the above example, I dynamically change the user control name of the edit form for the grid table. I then put the item in edit mode. This effectively renders the view control instead of the regular edit form control I have specified.

All the best,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Andrew
Top achievements
Rank 1
answered on 04 May 2010, 05:04 PM
This looks like it could work for me...let me give it a try.
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Veli
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or