2

I have a RadGrid control with template edit form implementation. I need to have a subset of controls in edit mode template different from the subset of controls in the add mode template. I found a way to do that scenario, but I'm not sure it's the best way.

I did this by setting the controls in panels. In the code behind, I checked the type of the form and, depending on the condition, these controls are turned on or off by setting the visibility property using this snippet:

protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
   {
       if (e.Item is GridEditFormInsertItem && RadGridConferences.MasterTableView.IsItemInserted)
       {
           Panel UploadConferenceImage = e.Item.FindControl("UploadConferenceImage") as Panel;
           Panel UploadConferenceNewsletter = e.Item.FindControl("UploadConferenceNewsletter") as Panel;
           Panel ConferenceImagePanel = e.Item.FindControl("ConferenceImagePanel") as Panel;
           RadEditor RadEditorConferenceTxtBody = e.Item.FindControl("RadEditorConferenceTxtBody") as RadEditor;
           if (UploadConferenceImage != null && UploadConferenceNewsletter != null && ConferenceImagePanel != null)
           {
               UploadConferenceImage.Visible = true;
               UploadConferenceNewsletter.Visible = true;
               ConferenceImagePanel.Visible = false;
           }
           else
               return;
           if (RadEditorConferenceTxtBody != null)
           {
               RadEditorConferenceTxtBody.Style.Add("margin-top", "55px");
           }
           else
               return;
       }
   }

Another option I found is creating my own custom editor.

David Makogon
  • 69,407
  • 21
  • 141
  • 189
user1162905
  • 33
  • 1
  • 5

1 Answers1

1

Your method is the best way I've found to use different sets of controls in a grid item template. You can have any elements you want in the edit template, then freely manipulate them in ItemDataBound().

Chris Tybur
  • 1,612
  • 2
  • 23
  • 38