开发者

Converting Dropdown list to int

hello mates i am trying to store value from dropdown list to an integer but i am getting an exception Input string开发者_运维知识库 was not in a correct format.

int experienceYears = Convert.ToInt32("DropDownList1.SelectedValue");

please help.


Remove the quotes; the code as it stands is trying to convert the literal string "DropDownList1.SelectedValue" to an integer, which it can't.

int experienceYears = Convert.ToInt32(DropDownList1.SelectedValue);


Try it without the quotes:

int experienceYears = Convert.ToInt32(DropDownList1.SelectedValue);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜