Hi
I have defined below dropdown list but i want Values should be saved as 0,1,2
C#
static List lst = new List() { "Monthly", "Quarterly", "HALF YEARLY", "YEARLY" };
public Incentives_Period()
{
}
public static List InCentivesPeriod
{
get
{
return lst;
}
}Thanks

Amit MohantyRank #112 · 20K reputationPosted Aug 26, 2024, 7:19 AM EDT
Try this:
private static readonly Dictionary incentivesPeriod = new Dictionary() { { 0, "Monthly" }, { 1, "Quarterly" }, { 2, "HALF YEARLY" }, { 3, "YEARLY" } }; public Incentives_Period() { } public static Dictionary IncentivesPeriod { get { return incentivesPeriod; } }Jithu ThomasRank #437 · 5.7K reputationPosted Aug 26, 2024, 7:21 AM EDT
Define a Class for the Dropdown Items
public class DropdownItem { public string Text { get; set; } public int Value { get; set; } }Populate the List with Objects
public class Incentives_Period { static List lst = new List() { new DropdownItem { Text = "Monthly", Value = 0 }, new DropdownItem { Text = "Quarterly", Value = 1 }, new DropdownItem { Text = "HALF YEARLY", Value = 2 }, new DropdownItem { Text = "YEARLY", Value = 3 } }; public Incentives_Period() { } public static List IncentivesPeriod { get { return lst; } } }Usage: -