Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 .

C#
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>


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 .
Posted
Updated 24-Oct-11 2:56am
v3
Comments
uspatel 24-Oct-11 8:56am    
pre tag added...

1 solution

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

i.e.

C#
void Page_Init(object sender, EventArgs e)
{

 XDocument xDocument = GetMyDocMethod();
 LoadXmlBugs(xDocument);
}
 
Share this answer
 
Comments
Emged 24-Oct-11 10:26am    
Ok it's good now . But the click event is still not working.
Emged 25-Oct-11 12:03pm    
It is still not firing, someone has an idea ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900