Hi,
Is it possible to load RowEditTemplate dynamically?
In UltraWebGrid on "Page_Init" I used to do following :
if (flag) { m_grid.Bands[0].RowEditTemplate = Page.LoadTemplate("~/Templates/Template1.ascx"); } else { m_grid.Bands[0].RowEditTemplate = Page.LoadTemplate("~/Templates/Template2.ascx"); }
How can I do the same thing in WebHierarchicalDataGrid, actually I need to have ability to change template depending on some conditions.
Thanks
Hi AlexanderZh,
Certainly, you can load the template dynamically. From your example I see your template is wrapped inside a user control.
Once you load the user control to the form you should be able to do as you wish with it:
Control myUserControl = (Control)Page.LoadControl("usr.ascx");
form1.Controls.Add(myUserControl);
Please let me know if you need any additional assistance regarding this matter.
Hi, Troy!
Thank you for your answer, but I don't undestand you, maybe my question wasn't very precise.
Once again, I don't want to specify template control at design time. I want to specify row edit template for the grid at "Page load" stage.
Yes, I can load user control dynamically and add it into forms' controls collection. But I want to set my user control as RowEdit template. In other words user makes double click on the row, my template is shown and the user control is shown on this template.
Alexander
Hi AlexanderZH,
Is your RowEditTemplate (RET) wrapped by a user control or does RowEditTemplate contain a user control?
Either way I remain unclear on the experience you are having. That is once you load the RowEditTemplate during page load, the template is loaded to the form. Provided you have your grid wired to use the RET for editing in behaviors, the RET should show when you double click a row to enter edit mode.
Is it the case that when you double click on a row to enter edit mode that you are not getting the RET? Or are you getting an error?
Perhaps you can show your code-behind?
Please let me know if I can be of further assistance regarding this matter.
Yes, I need the assistance because I've not got the answer.
Yes, my RowEditTemplate contains a user control. In all samples all edit controls (textboxes, numeric-editors, and so on) are located on the same page where the grid is located. But I've put the on separate user control (because there a lot of them and I use different templates for different bands. If I've put them all on one page it will be very inconvenient).
The question is how can I specify that this certain user control must be used as template, but I want (have) to do it in apsx.cs file(not in mark-up aspx page),
for example on Page_Load stage something like this: grid.behaviours().editingCore.RowEditTemplate = myUserControl;
You can do the similar with the WebHierarchicalDataGrid by changing your line of code minimally to something like this:
this.WebDataGrid1.Bands[0].Behaviors.EditingCore.Behaviors.RowEditTemplate.Template = Page.LoadTemplate("~/Templates/Template1.ascx");
Let me know if you need any additional assistance regarding this matter
I am developing an example for you to reference. I will follow-up with you regarding this again on or before Thursday.