문제

Below is part of the code I am using to create a new chart dynamically on a asp.net page. It throws the "Object reference not set to an instance of an object" error on chart1_holder.Controls.Add(chartCtrl);. Any reason why this is happening?

Chart chartCtrl;
chartCtrl = new Chart();

chart1_holder.Controls.Add(chartCtrl);

chartCtrl.DataBind();

ASP page

 <div id ="chart1_holder" runat="server" style="height:95%; width:100%"> </div>
도움이 되었습니까?

해결책

Do you know at what point in the ASP.NET pipeline this code runs e.g.(Init,Load etc..)? It maybe that chart1_holder has not been initialised causing the null reference exception at the point you try to access any of its properties.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top