0
我试图从代码隐藏服务加载用户控件并获取它的html值。但是有一个在未得到加载/初始化时控制一个中继器,使得它一直空在asp.net中获取用户控件html
我得到
Object reference not set to an instance of an object.
的loadOrderInvoiceView内功能时,它会尝试
// fill repeater
this.rptView.DataSource = result;
this.rptView.DataBind();
在它说的行this.rptView.DataSource = result; ...我试着调试和出于某种原因this.rptView是空
而这里的服务电话提前
StringBuilder sb = new StringBuilder();
StringWriter tw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(tw);
//ctrl.RenderControl(hw);
myControls.OrderInvoiceView oiv = new myControls.OrderInvoiceView();
oiv.loadOrderInvoiceView(OID);// load the control with order id
oiv.RenderControl(hw);
return sb.ToString();
感谢您的任何想法。我使用.NET 4
你是如何初始化'这一点。 rptView'? – lsuarez 2011-12-29 22:56:38
我努力使控制将自动初始化它..无论如何,我会回答我自己的问题。我刚刚发现如何解决它 – robert 2011-12-29 23:03:23
可能的重复[如何获得.NET(C#)中的用户控件的HTML输出?](http://stackoverflow.com/questions/288409/how-do-i -get-的-HTML的输出对的一用户控件功能于净-c)的 – 2011-12-29 23:16:15