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

RadGrid dynamically Load User Control in InstantiateIn have issues

1 Answer 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Twu
Top achievements
Rank 1
Twu asked on 16 Sep 2013, 05:24 PM
Here is the link I posted on the asp.net: 

http://forums.asp.net/t/1935517.aspx?Load+userControl+first+time+get+called+and+load+properly+Page_Load+then+click+on+the+Sorting+or+pageSize+changed+on+the+RadGrid+that+control+did+not+load

Here is my iTemplate class: 
        public class iTemplate : ITemplate
        {
            private string columnName;
            Page page; 

            public iTemplate(string cName, Page page)
            {
                columnName = cName;
                this.page =page; 
            }

            public void InstantiateIn(System.Web.UI.Control container)
            {
                Control ctrl = new Control();
                
                //System.Web.UI.
                
                //MWStringCrtl mwstringCtrl = (MWStringCrtl)loadMwstringCtrl();
                MWStringCrtl mwstringCtrl = (MWStringCrtl)page.LoadControl("~/ServiceModules/Controls/MWStringCrtl.ascx");
                mwstringCtrl.Wrapper = new MWStringCrtl.DataWrapper();
                mwstringCtrl.ID =container.ClientID+ "_mctrl";
                mwstringCtrl.DataBinding += new EventHandler(this.BindData);
                mwstringCtrl.Wrapper.ValueOnNewLine = false;
                mwstringCtrl.Wrapper.ValueFontSize = 12;
                SimpleStringDto blankCell = new SimpleStringDto();
                blankCell.Text = "hello";

                mwstringCtrl.Wrapper.Data = blankCell; 
                container.Controls.Add(mwstringCtrl);
            }


            public void BindData(object sender, EventArgs e)
            {
                MWStringCrtl mc = (MWStringCrtl)sender;
                GridDataItem container = (GridDataItem)mc.NamingContainer;
                mc.Wrapper = (MWStringCrtl.DataWrapper)((RowDataWrapper)container.DataItem).GetType().GetProperty(columnName).GetValue((RowDataWrapper)container.DataItem, null);
            }
        }

when load the Grid first time, first instantiateIn the User control and bind the data, and lastly Page_Load the dynamically user control. 

However, when Sorting or paging, first Instantiateln the User control and Page_Load the dynamically User Control, and last Bind the Data, which in result will have the empty Grid. 

anybody can help, it is urgent? 

Thanks,T

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 19 Sep 2013, 12:02 PM
Hi Twu,

I guess the issue has been resolved in the mentioned thread. Please feel free to contact us if new issues arise.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Twu
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or