My page consists of a table containing both buttons and radiobuttons. Each have a seperate event handler. My problem is as follows: when I click on a button, the button AND the radiobutton event handler are called instead of just the first. When I click on a radiobutton nothing happens. I assume there is a confliction here because two event handlers are used in one method. How do I solve this?
This is what my event handlers look like:Code:protected void CreateTblMainSkill() { int i = 0; // Create a cell with a skill in each row foreach(object skill in criterium) { btnSkill = new Button(); cellSkill = new TableCell(); rowSkill = new TableRow(); btnSkill.ID = Convert.ToString(criterium[i].ID); btnSkill.Text = Server.HtmlDecode(criterium[i].Skill); cellSkill.Controls.Add(btnSkill); rowSkill.Controls.Add(cellSkill); // On button click display side table for desired skill btnSkill.Click += new EventHandler(btnSkill_CheckedChanged); // PROBLEM LIES HERE // For every skill add rbtn for each ENumGrade for (int c = 0; c < eNumGradesList.Length; c++) { cellRbtn = new TableCell(); rbtnSkill = new RadioButton(); rbtnSkill.ID = Convert.ToString(criterium[i].ID) + " , " + c; rbtnSkill.Checked = false; rbtnSkill.GroupName = Convert.ToString(criterium[i].Skill); cellRbtn.Controls.Add(rbtnSkill); rowSkill.Controls.Add(cellRbtn); rbtnSkill.CheckedChanged += new EventHandler(rbtnSkill_CheckedChanged); // PROBLEM ALSO LIES HERE } // Add the following rows to the stage tblMain.Rows.Add(rowSkill); i++; } }
Code:private void btnSkill_CheckedChanged(object sender, EventArgs e) { MessageBox("Test: Button Event handler"); } protected void rbtnSkill_CheckedChanged(object sender, EventArgs e) { MessageBox("Test: Radiobutton event handler!"); }




Reply With Quote
