Hi,
I am using templates for row editing.The mark-up is something like this. The question is how can I get access to shiftsTemplate control on server side.
<ig:RowEditingTemplate Enabled="true"> <Template > <controls:ShiftTemplate ID="shiftsTemplate" runat="server"/> </Template> </ig:RowEditingTemplate>
I've tried following:
var mycontrol = (ShiftTemplate)m_grid.Behaviors.EditingCore.Behaviors.RowEditTemplate.Template ;
but that doesn't work.
Please help.
I've tried following this recomendation, but they doesn't work either:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2010.1/CLR3.5/html/WebDataGrid_Binding_Controls_in_Row_Editing_Template.html
Hello Alexander;
Template is simply the ITemplate which defines what appears in edit template. In order to get template you need to find it off of GridView. The below line of code will finds template:
TemplateControl templ = (TemplateControl)this.WebHierarchicalDataGrid1.GridView.TemplateControl;
I hope this helps.
Hi, Bhadresh!
I've tried the suggested approach, but it doesn't work.
This property this.WebHierarchicalDataGrid1.GridView.TemplateControl for some reasons returns me the UserControl where my WebHierarchicalDataGrid is located.
Are you sure your approach is working? If yes I'll prepare a small sample for you that demonstrates the problem.
Alexander
I was able to see that the code I have suggested finds the user control. I am working with development on this functionality. I will update you further by the end of the day tomorrow with more details on this.
Thank you!
I am waiting for details on this!
Hello Alexander,
Based on update from development, I understand you may access row edit template on parent grid as shown below:
TemplateContainer temp = (TemplateContainer)this.WebHierarchicalDataGrid1.GridView.Behaviors.EditingCore.Behaviors.RowEditTemplate.TemplateContainer;
I am just following up to see if you were able to find user control from row edit template based on details I have provided above.
Feel free to update me if any further assistance needed.
I was able to get user control as well as other controls used in row edit template. I was also able to add controls in user control at runtime also using below lines of code:
TemplateContainer temp = (TemplateContainer)this.WebHierarchicalDataGrid1.GridView.Behaviors.EditingCore.Behaviors.RowEditTemplate.TemplateContainer;Button btn1 = (Button)temp.FindControl("Button2");btn1.Text = "chaged";
//Find User ControlUserControl usr = (UserControl)temp.FindControl("Usrt1");
//Add Button to User ControlButton btn2 = new Button();btn2.ID = "btn1";btn2.Text = "I ADD1";btn2.Height = Unit.Pixel(100);btn2.Width = Unit.Pixel(100);usr.Controls.Add(btn2);
I have tried below mark up for Row Editing Template:
<ig:EditingCore><Behaviors><ig:RowEditingTemplate CancelButton="buttonCancel" OKButton="buttonOK"><Template><asp:Button ID="Button2" runat="server" Text="Button" /><uc1:Usrt ID="Usrt1" runat="server" /></Template></ig:RowEditingTemplate></Behaviors></ig:EditingCore>
Thank you for your answer,
but I don't want to get TemplateContainer, I need to get my own UserControl.
Actually before I wrote the question here I'd tried a lot of variants, including the suggested one.
So could you please ask development for other variants?
Alexander.