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

what is the best way to have two different templates in edit mode and insert mode ?

2 Answers 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rasheed
Top achievements
Rank 1
Rasheed asked on 21 Jan 2012, 09:28 PM
hi 
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've found a way to do that scenario but i'm not sure cause i'm new to Telerik Rad Controls and i did that by setting the controls in panels, at the code behind I've checked the type of the form and depending on the condition these controls 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, please i need an advice, any help !! 

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 22 Jan 2012, 01:08 AM
Hello Rasheed,

Depending on the condition these controls turned on or off by setting the visibility of panels.

or if you do not want to set this visiblity dynamically then you can also use below code and for more information please check this link.

Visible='<%#  (Container is GridEditFormInsertItem) %>'


Thanks,
Jayesh Goyani
0
Rasheed
Top achievements
Rank 1
answered on 22 Jan 2012, 01:24 AM
thanks for reply 
so it's a good practice to use this scenario ?? and if you please tell me when to use the custom editor approach ? 

thank you 
Tags
Grid
Asked by
Rasheed
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Rasheed
Top achievements
Rank 1
Share this question
or