I am using Convert.ToInt32(ddlBuyer1Country.SelectedValue)
; to typecast a string returned by selectedvalue.
But this is giving me 0 instead of 3. I have selected value as 3 in this case.
views:
51answers:
2
A:
Convert will return a 0, if the value is null.
Are you sure SelectedValue is not null before calling Convert?
How are you using the ddlBuyer1Country?
David Basarab
2010-05-14 13:04:08
+2
A:
Try: Int.TryParse(ddlBuyer1Country.SelectedValue, out myInt);
But double check to make sure that you are not re-binding the dropdown on postback, that could reset your selected value to 0. Make sure the dropdown bind only occurs in a:
if(!Page.IsPostBack)
derek
2010-05-14 13:04:19