动态链接按钮请点击 [英] Dynamically Linkbutton Click

查看:77
本文介绍了动态链接按钮请点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目有问题.我正在动态创建链接按钮以显示项目.当我单击一个项目时,它将触发,并且可以动态显示错误的链接按钮.现在,当我单击错误时,我也想动态显示说明,但是此click事件没有触发,而且我无法修复..这是我的代码.

I have a problem with my project . I am creating link buttons dynamically to show the projects. When I click on a project it is firing and I can display link buttons of bugs dynamically . Now when I click on a bug , I want to display the description, dynamically too , but this click event is not firing , and I can''t fix it .. This is my code .

private void LoadXmlBugs(XDocument xDocument)
    {
        //Load all bugs
        IEnumerable<bugs> data = from query in xDocument.Descendants("bugs")
                                 where (((string)query.Element("bug_status") == "NEW") ||
                                 ((string)query.Element("bug_status") == "REOPENED") ||
                                 ((string)query.Element("bug_status") == "New"))
                                 select new Bugs
                                 {
                                     Bug_Id = (string)query.Element("bug_id"),
                                     Short_Desc = (string)query.Element("short_desc"),
                                     Bug_Status = (string)query.Element("bug_status"),
                                     Priority = (string)query.Element("priority"),
                                     Creation_Ts = (string)query.Element("creation_ts"),
                                 };

        Bugs = new List<bugs>(data);
        string statut = Request.QueryString.Get("bug_status");

        foreach (Bugs b in Bugs)
        {

            System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
            img.ImageUrl = ("~/Img/FolderIco.png");
            PanelAllBugs.Controls.Add(img);
            LinkButton lkButtonBugs = new LinkButton();
            lkButtonBugs.Click += new EventHandler(lkButtonBugs_Click);
            lkButtonBugs.ID = b.Bug_Id;
            lkButtonBugs.Tag = b.Short_Desc;
            lkButtonBugs.Text = b.Bug_Status + "     " + b.Short_Desc + "      " + "<br>";
            lkButtonBugs.Attributes.Add("runat", "server");
            PanelAllBugs.Controls.Add(lkButtonBugs);

        }
    }


void lkButtonBugs_Click(object sender, EventArgs e)
    {
        bugId = ((sender as LinkButton).ID);

        LoadTheDescriptionForABug(bugId, ((sender as LinkButton).ID));
        LoadBugsComments();
        LoadBugsAttachments();
    }

</br></bugs></bugs>



在我的PageLoad中,我仅加载项目.每个项目都是一个带有click事件的链接按钮.因此,当我单击一个项目时,会显示该项目的所有错误.我还创建了一个带有click事件的bug的新linkbutton.我不知道为什么这些论文不被解雇.我试图将LoadXmlBugs放在Page_Init中,但是什么也没有发生.然后单击项目linkbutton来调用LoadXmlBugs.然后,当我单击这些错误之一时,应显示说明...单击不会触发

有人可以帮我吗?

非常感谢.



In my PageLoad I load only the projects . Each project is a linkbutton with a click event . So when I click on a project i display all the bugs for this project . And I create also new linkbuttons of bugs, with a click event . I don''t know why theses are not firing. I tried to put LoadXmlBugs in the Page_Init but nothing happens. And I call LoadXmlBugs on the click of the project linkbutton . Then when I click on one of these bugs I should display the description ... Click doesn''t fire

Can someone help me ?

Thank you very much .

推荐答案

您必须执行方法"LoadXmlBugs(XDocument xDocument)"
用于每次调用Page_Init()方法来重新创建eventHandler.



you have to execute the method " LoadXmlBugs(XDocument xDocument)"
for each call of Page_Init() method for recreating the eventHandler.

i.e.

void Page_Init(object sender, EventArgs e)
{

 XDocument xDocument = GetMyDocMethod();
 LoadXmlBugs(xDocument);
}


这篇关于动态链接按钮请点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆