asp.net DropDownList控件“选不中”的项

DropDownList控件  选中某项(删除等其他操作)跑到服务端常发现list.SelectedIndex索引并不是真实的项。

选择任何一项,客户端脚本可以得到正确索引,但服务端得到的索引都是0.

因为DropDownList控件的索引属性,是通过客户端传过去value值来计算出来的索引。value值得到第一个匹配项为第一个,故以为是第一项了。

所以<asp:ListItem Value=""></asp:ListItem>

中的Vaule属性删掉,或者和其他项不重复则可以得到正确索引

猜你喜欢

转载自blog.csdn.net/zj53hao/article/details/4044933