usercontrol in insert and edit

2 posts, 0 answers
  1. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 18 Apr 2012 Link to this post

    How to show different user controls in edit and insert mode?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Apr 2012 Link to this post

    Hello Tina,

    You can check for the CommandName in ItemCommand event and show corresponding UserControls.
    C#:
    protected void grid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
     if (e.CommandName == RadGrid.InitInsertCommandName)
      {
         e.Item.OwnerTableView.EditFormSettings.UserControlName = "WebUserControl1.ascx";
         e.Item.OwnerTableView.InsertItem();
      }
       else if (e.CommandName == RadGrid.EditCommandName)
       {
          e.Item.OwnerTableView.IsItemInserted = false;
          e.Item.OwnerTableView.EditFormSettings.UserControlName = "WebUserControl2.ascx";
       }
    }

    Thanks,
    Princy.
Back to Top