I have some code which fires when user selects an item in dropdownlist. Now I want the same code to fire when I set selectedindex programmatically.
I have tried setting
ddlSystemLevelDCP.SelectedIndex=2;
and this as well
ddlSystemLevelDCP.SelectedValue="2";
None of them fires this event. However when user changes the selection, this event fires.
Set your selected index. say, 2 and then call that event with null arguments.
ddlSystemLevelDCP.SelectedIndex=2;
ddlSystemLevelDCP_SelectedIndexChanged(null,null);
This should work.
If you have event handler, you can call it.
<asp:DropDownList ID="ddlSystemLevelDCP" runat="server"
AutoPostBack="true"
onselectedindexchanged="ddlSystemLevelDCP_SelectedIndexChanged">
</asp:DropDownList>
...
...
...
ddlSystemLevelDCP_SelectedIndexChanged(ddlSystemLevelDCP,EventArgs.Empty);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With