¿Por qué los gráficos dinámicos de asp.net se representan solo después de la segunda page_load?

I am using web forms to develop a web application. From the very beginning, I have always been surprised by the page_load event being fired twice, and finally today I found out that all gridviews and texts are rendered after first page_load, and it takes another page_load to render all the dynamic asp.net charts..

why is it so, is there an attribute on the chart web server control that I can use to bypass this?

preguntado el 08 de noviembre de 11 a las 17:11

The page_load event should not be firing twice. The charts should render immediately. There must be something wrong in your code. Why don't you post a small sample that illustrates the problem? -

protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Chart1Bind(); } } protected void Chart1Bind() { //fetching values for the charts Chart1.Series["Series1"].Points.DataBindXY(x1, y1); //formatting stuff comes here } -

Take the Chart1Bind function OUT of the IsPostBack clause. -

I do not think so, because I tested without IsPostBack, it is the same story.. -

And I need IsPostBack since I am using AJAX UpdatePanel -

1 Respuestas

Check to see if you "AutoEventWireup" set to true. If this is a control, check the parent control/page also. Even if the control itself is set to false, but the parent is set to true, it seems to fire anyway. Also check where you assign listener to Page_Load evento:

this.Load += new System.EventHandler(this.Page_Load);

Debería estar en InitializeComponent Método

respondido 08 nov., 11:22

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.