Convert string to Enumeration
-
Hi All, Greetings. I've to assign the enum value to a object property. Which shows the following error. Cannot convert type 'string' to 'Common.Enumerations.OffDate'
searchUIO.OffDate = (OffDate)ddlOffDate.SelectedValue;
in this (OffDate) is an enum. the drop down list will contain the values lastweek, lastmonth like that. so i have to assing the value to the lefthand site object. thanks in advance Regards babu -
Hi All, Greetings. I've to assign the enum value to a object property. Which shows the following error. Cannot convert type 'string' to 'Common.Enumerations.OffDate'
searchUIO.OffDate = (OffDate)ddlOffDate.SelectedValue;
in this (OffDate) is an enum. the drop down list will contain the values lastweek, lastmonth like that. so i have to assing the value to the lefthand site object. thanks in advance Regards babuTake a look at the static
Enum.Parse
method.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
Hi All, Greetings. I've to assign the enum value to a object property. Which shows the following error. Cannot convert type 'string' to 'Common.Enumerations.OffDate'
searchUIO.OffDate = (OffDate)ddlOffDate.SelectedValue;
in this (OffDate) is an enum. the drop down list will contain the values lastweek, lastmonth like that. so i have to assing the value to the lefthand site object. thanks in advance Regards babu -
Hello, As enum is an int type, you could make the enum casting with the SelectedIndex method. searchUIO.OffDate = (OffDate)ddlOffDate.SelectedIndex; All the best, Martin
-
Thank you for your response. But i need to take the text value from the dropdown list.how i can do that??? Could you tell me the solution. regards babu