Reputation: 263
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.
Upvotes: 3
Views: 5714
Reputation: 24385
Try it without the quotes:
int experienceYears = Convert.ToInt32(DropDownList1.SelectedValue);
Upvotes: 1
Reputation: 185663
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);
Upvotes: 7