Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
C#
public enum CompetencyLevels
      {
          [EnumMember(Value = "Below my grade")]
          Belowmygrade = 1,

          [EnumMember(Value = "At my grade")]
          Atmygrade = 2,

          [EnumMember(Value = "Above my grade")]
          Abovemygrade = 3
      }



C#
public static void BindCompetencyLevelToDropDown(ref DropDownList dropDownList)
    {
        dropDownList.DataSource = Enum.GetNames(typeof(CompetencyLevels)).
        Select(o => new { Text = o, Value = (int)(Enum.Parse(typeof(CompetencyLevels), o)) });
        dropDownList.DataTextField = "Text";
        dropDownList.DataValueField = "Value";
        dropDownList.DataBind();
    }




This is what i tried ..but .. my dropdown text is not as per rewuired .. i want to ve displayed with spaces.. and value to be assign as 1 , 2 .. as given
Posted

1 solution

 
Share this answer
 
Comments
Torakami 11-Apr-14 6:18am    
in the fiorst link .. how to get values .. like 1 , 2 , 3
Torakami 11-Apr-14 6:25am    
please provide me solution based on what i tried .. links i can search also ..in the above my code .. i am getting the value and result as well ... but text fiersld is not as per required .. so just help e in that area..
Naz_Firdouse 11-Apr-14 6:28am    
you mean to say you want to display 1,2,3 in the dropdownlist?
Torakami 11-Apr-14 6:42am    
no , thats the value.. that value should go to the database ..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900