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

Dynamically change EditMode serverside

1 Answer 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Glenn
Top achievements
Rank 1
Glenn asked on 12 Sep 2012, 07:27 PM
Hi,

Is it possible to dynamically change a Radgrid's EditMode from "InPlace" to "PopUp" from a server side event?

I have a grid in which I want to do Inline editing for an Insert, but a custom web control for Edit.

I tried using the ItemCommand event and changing the grid's EditMode value (see example below), but it still opens in Inline mode.

 

 

protected void radGridPeople_ItemCommand(object sender, GridCommandEventArgs e)
{
    try
    {
        if (e.Item.OwnerTableView.Name == "PersonConditionGrid")
        {
            if (e.CommandName == RadGrid.EditSelectedCommandName)
            {
                e.Item.OwnerTableView.EditMode = GridEditMode.PopUp;
                e.Item.OwnerTableView.EditFormSettings.UserControlName = "PeopleMaint/PersonCondAction.ascx";
            }
        }
    }
    catch (Exception ex)
    {
        ErrorHandler.WriteErrorLog(GenFunctions.CurrentUserName, System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
        generalCustomValidator.ErrorMessage = ex.Message + "<br/>" + ex.StackTrace;
        generalCustomValidator.IsValid = false;
    }
}

 

 

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 17 Sep 2012, 08:29 AM
Hi Glenn,

Your approach is correct. Could you please try to modify your code-behind slightly?
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.EditCommandName)
    {
        e.Item.OwnerTableView.EditMode = GridEditMode.PopUp;
        e.Item.OwnerTableView.EditFormSettings.EditFormType = GridEditFormType.WebUserControl;
        e.Item.OwnerTableView.EditFormSettings.UserControlName = "WebUserControl.ascx";
    }
    else if (e.CommandName == RadGrid.InitInsertCommandName)
    {
        RadGrid1.MasterTableView.EditMode = GridEditMode.InPlace;
        e.Item.OwnerTableView.EditFormSettings.EditFormType = GridEditFormType.AutoGenerated;
    }
}

That should do the trick. Please give it a try and let me know about the result.

Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Glenn
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or