I have a radiobutton list that has a SelectedIndexChanged attached to it. So a user changes the radiobutton and
SelectedIndexChanged is triggere.
Let's say I manually change the radiobutton list value in page_load, what would I need to do so that it automatically fires SelectedIndexChanged?
Basically emulate the user functionality, but from codebehind.
Currently, the eventhandler is not triggered when I change the value from codebehind.
What you'll want to do is put the code that is in the SelectedIndexChanged event into a new method. Then have the event call that method. This will allow you to also call that method from your PageLoad event when you set the value
Have you read the book? - ASP.Net 3.5 CMS Development (now on Kindle)
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
Did you set the Autopost back = true for the RadioButton List. Otherwise the event won't fire. Then in the SelectedIndexChanged Event write up your code ..
vmhatup
Member
292 Points
516 Posts
Dynamically changing control value and triggering eventhandler?
May 03, 2012 02:18 PM|LINK
I have a radiobutton list that has a SelectedIndexChanged attached to it. So a user changes the radiobutton and SelectedIndexChanged is triggere.
Let's say I manually change the radiobutton list value in page_load, what would I need to do so that it automatically fires SelectedIndexChanged? Basically emulate the user functionality, but from codebehind.
Currently, the eventhandler is not triggered when I change the value from codebehind.
Thanks.
Curt_C
All-Star
66014 Points
7639 Posts
Moderator
Re: Dynamically changing control value and triggering eventhandler?
May 03, 2012 02:57 PM|LINK
the event wouldnt trigger, nor should it.
What you'll want to do is put the code that is in the SelectedIndexChanged event into a new method. Then have the event call that method. This will allow you to also call that method from your PageLoad event when you set the value
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
vmhatup
Member
292 Points
516 Posts
Re: Dynamically changing control value and triggering eventhandler?
May 03, 2012 03:12 PM|LINK
Thanks for your reply.
I could also call the event handler.
sushanth009
Contributor
6243 Points
1168 Posts
Re: Dynamically changing control value and triggering eventhandler?
May 03, 2012 03:16 PM|LINK
Did you set the Autopost back = true for the RadioButton List. Otherwise the event won't fire. Then in the SelectedIndexChanged Event write up your code ..
Curt_C
All-Star
66014 Points
7639 Posts
Moderator
Re: Dynamically changing control value and triggering eventhandler?
May 04, 2012 12:20 PM|LINK
Absolutely, its just not a common, nor a good way in my opinion, to handle this.
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!