{
        switch (w)
        {
            case 1:
                this.ZedGraphWeb1.RenderGraph += new ZedGraphWebControlEventHandler(this.OnRenderGraph1);
                break;
            case 2:
                this.ZedGraphWeb1.RenderGraph += new ZedGraphWebControlEventHandler(this.OnRenderGraph2);
                break;
        }
        this.Load += new System.EventHandler(this.Page_Load); protected void Linkbutton1_Click(object sender, EventArgs e)
    {
        w = 1;
        {
         BindData();
        }  
           InitializeComponent(w);
    }
就是想在单击Linkbutton1的时候,运行到这里private void InitializeComponent(int w),如何操作啊,各位大哥给个意见吧!!

解决方案 »

  1.   

    前面是这样的:
    private void InitializeComponent(int w)
        {
            switch (w)
            {
                case 1:
                    this.ZedGraphWeb1.RenderGraph += new ZedGraphWebControlEventHandler(this.OnRenderGraph1);
                    break;
                case 2:
                    this.ZedGraphWeb1.RenderGraph += new ZedGraphWebControlEventHandler(this.OnRenderGraph2);
                    break;
            }
            this.Load += new System.EventHandler(this.Page_Load);
      

  2.   

    就是我单击Linkbutton1_Click的时候,运行到了InitializeComponent(w),之后,想让程序运行private void InitializeComponent(int w)
    这一块中的代码。这样才能弹出曲线吧? 高手们指教下
      

  3.   

    你个InitializeComponent(w)这个方法搞个返回值吧,然后在Linkbutton1_Click里面判断返回值是什么的时候就执行
      

  4.   

    在点击事件直接这样写
    if (w==1)
       {
       this.ZedGraphWeb1.RenderGraph += new ZedGraphWebControlEventHandler(this.OnRenderGraph1);
    else if(w==2)
       this.ZedGraphWeb1.RenderGraph += new ZedGraphWebControlEventHandler(this.OnRenderGraph2);
       }
    else{
    this.Load += new System.EventHandler(this.Page_Load);
    点击事件放这里
    }   
      

  5.   

    public partial class WebUI_History : System.Web.UI.Page
    {
        DataSet ds = new DataSet();
        string strTerminalID = "";
        int w;    //曲线
        private void InitializeComponent(int w)
        {
            switch (w)
            {
                case 1:
                    this.ZedGraphWeb1.RenderGraph += new ZedGraphWebControlEventHandler(this.OnRenderGraph1);
                    break;
                case 2:
                    this.ZedGraphWeb1.RenderGraph += new ZedGraphWebControlEventHandler(this.OnRenderGraph2);
                    break;
            }
            this.Load += new System.EventHandler(this.Page_Load);
    }private void OnRenderGraph1(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
        {
            GraphPane myPane = masterPane[0];        myPane.YAxis.Scale.Max = 60;
            myPane.YAxis.Scale.Min = 0;        myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.MajorGrid.Color = Color.LightGray;
            myPane.YAxis.MajorGrid.Color = Color.LightGray;
            myPane.XAxis.MajorGrid.DashOff = 0;
            myPane.YAxis.MajorGrid.DashOff = 0;        myPane.YAxis.Scale.BaseTic = -40;
       
            myPane.XAxis.Scale.MajorStep = 10;
            myPane.XAxis.Scale.MinorStep = 2.5;
        
            myPane.YAxis.Scale.MajorStep = 10;
            myPane.YAxis.Scale.MinorStep = 2.5;        myPane.YAxis.Scale.IsVisible = true;        myPane.Title.Text = "温度曲线图";
            myPane.XAxis.Title.Text = "时间";
            myPane.YAxis.Title.Text = "温度";        myPane.Chart.Fill = new Fill(Color.White,Color.SteelBlue,45.0F);
            myPane.AxisChange(g);
            myPane.Draw(g);        DataSourcePointList dspl = new DataSourcePointList();        dspl.DataSource = GetData().Tables[0];
     
            dspl.XDataMember = "Timestamp";        dspl.YDataMember = "Air_Temperature";        dspl.ZDataMember = null;        LineItem myCurve2 = myPane.AddCurve("温度℃", dspl, Color.LightGray, SymbolType.Plus);        myPane.XAxis.Type = AxisType.Date;
            myPane.XAxis.CrossAuto = true;        myPane.Chart.Fill = new Fill(Color.Black, Color.Black, 45F);
            masterPane.AxisChange(g);
    }
      

  6.   

     //温度
        protected void Linkbutton1_Click(object sender, EventArgs e)
        {
            w = 1;
            {
               this.ZedGraphWeb1.RenderGraph +=new ZedGraphWebControlEventHandler(this.OnRenderGraph1);
               this.Load += new System.EventHandler(this.Page_Load);
            }
            InitializeComponent(w);
        }
      

  7.   

    代码差不多是这样,目的是想要单击linkbutton1,弹出绘制的曲线图