How to raise the SelectedIndexChanged event of an asp.net List control in a codebehind using C#?
How to raise the SelectedIndexChanged event of an asp.net List control in a codebehind
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re asking how to manually fire the event so that it can run whatever logic is attached: don’t.
Your event handlers should be slim. If you need to perform the same operation from multiple places, then extract that functionality into its own method and have the event handler invoke that. For example:
Now instead of trying to fire the
SelectedIndexChangedevent, you just invoke the method that this event handler refers to, i.e.Don’t put complex logic in event handlers and try to raise those events from unexpected places. Instead, put the complex logic in its own method, so that you can perform the associated actions from elsewhere.