asp.net – 如何以编程方式触发dropdownlist.selectedindexchanged事件

前端之家收集整理的这篇文章主要介绍了asp.net – 如何以编程方式触发dropdownlist.selectedindexchanged事件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一些代码用户选择下拉列表中的项目时触发.现在,我想以编程方式设置selectedindex时触发相同的代码.

我试过设置

ddlSystemLevelDCP.SelectedIndex=2;

这也是

ddlSystemLevelDCP.SelectedValue="2";

他们都没有解雇这个事件.但是,当用户更改选择时,将触发此事件.

解决方法

设置所选索引.比如说2然后用null参数调用该事件.
ddlSystemLevelDCP.SelectedIndex=2;
ddlSystemLevelDCP_SelectedIndexChanged(null,null);

这应该工作.

原文链接:https://www.f2er.com/aspnet/247514.html

猜你在找的asp.Net相关文章