[RESOLVED] Adding an Event at runtime C#
Hi All,
I have the following signature for a function:
Code:
protected void Option_SelectedIndexChanged(object sender, EventArgs e)
{.......}
in another event Im creating a buttonlist control:
Code:
RadioButtonList myradiobuttonlist = new RadioButtonList();
myradiobuttonlist.AutoPostBack = true;
myradiobuttonlist.ID = "RoomOptionsRadioButtonList" + roomIndex.ToString();
I need to bind myradiobuttonlist SelectedIndexChanged event to my method above, how do I do that please. I thought it might be the following, but the compiler doesn't like it.
Code:
myradiobuttonlist.SelectedIndexChanged += new Option_SelectedIndexChanged(myradiobuttonlist,new System.EventArgs);
Although I think I need to Bind to the Option_SelectedIndexChanged event, it might be ok if it has it's own event and this event calls Option_SelectedIndexChanged.
Re: Adding an Event at runtime C#
Change it to
Code:
myradiobuttonlist.SelectedIndexChanged += new EventHandler(Option_SelectedIndexChanged);
Re: Adding an Event at runtime C#
Thanks, that did the trick. I was over complicating it with trying to use delegates. Doh!...