请问我是动态生成的linkbutton,如何添加他的click事件啊

解决方案 »

  1.   

    在你动态生成的代码后边加上
    linkbutton称.click += new .......(事件处理方法)
      

  2.   

    就像这段代码一样
    private void Button1_Click(object sender, System.EventArgs e)
    {
    LinkButton lb = new LinkButton();
    lb.Click += new EventHandler(lb_Click);
    } private void lb_Click(object sender, EventArgs e)
    { }
      

  3.   

    while(this.myReader1.Read())
      {

        Vtitle = myReader1[0].ToString();

        LinkButton myLbtn = new LinkButton();
        myLbtn.Text = Vtitle;
        myLbtn.ID = "" + btnID++;
        myLbtn.Style.Add("display","block");
        FindControl("ViewForm1").Controls.Add(myLbtn); 
        myLbtn.Click += new System.EventHandler(this.LinkButton_Click) ;
    }
    this.myReader1.Close();
    Vtitle 是我读出来的文件名,里面有用户生成的文件,我想把它动态赋给linkbutton,让用户点哪个linkbutton就链接到哪个文件名的页面中去
      

  4.   

    private void LinkButton_Click(object sender, System.EventArgs e)//显示选择的项 
    {
    this.file = new FileOperation();
    string FullPath = Server.MapPath("../html/eee.html");//路径
    this.file.ReadFile(FullPath);

    }这样写对吗,FileOperation()是我的一个类
      

  5.   

    this.linkLabel1.LinkClicked+=new name(...);如此做一个委托不可以吗?