开发者

Disabling Viewstate Causes selected dropdown values to default to -1

I don't get this. So I disable viewstate on my .aspx page. I then select options from 3 dropdown menus and then on submit check the values and they are all -1. I put ViewState back on and do the same, select values and now in the submit event they're all set to a valid value for the SelectedIndex.

I don't get this. I don't see how viewstate has anything to do with selecting values in a dropdown and then calling a server-side handler to pick up thos开发者_C百科e selected values in order to do something with it and in order to get the actual valid SelectedIndex values that the user selected. I don't see why it would give me a -1 if I disable viewstate for the SelectedIndex for each of those 3 dropdownlist controls.


Either move your code that binds the dropdowns into Page_Init or surround them with

if (!IsPostPack) { ... }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜