|
-
February 23rd, 2009, 02:07 PM
#1
[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.
Last edited by Bill Crawley; February 24th, 2009 at 02:29 PM.
If you find my answers helpful, dont forget to rate me 
-
February 25th, 2009, 08:54 AM
#2
Re: Adding an Event at runtime C#
Change it to
Code:
myradiobuttonlist.SelectedIndexChanged += new EventHandler(Option_SelectedIndexChanged);
-
February 27th, 2009, 04:30 AM
#3
Re: Adding an Event at runtime C#
Thanks, that did the trick. I was over complicating it with trying to use delegates. Doh!...
If you find my answers helpful, dont forget to rate me 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|