Ejemplo n.º 1
0
        /// <summary>
        /// Get item identifier
        /// </summary>
        /// <param name="name">Name</param>
        /// <returns>Identifier</returns>
        public int GetItemId(object name)
        {
            if (string.IsNullOrEmpty(name?.ToString()))
            {
                return(0);
            }

            if (!int.TryParse(name.ToString(), out var id))
            {
                id = 0;
            }

            return(Convert.ToInt32(DropDownElements.FirstOrDefault(ev => ev.Text.Trim() == name.ToString().Trim())?.Value ?? id.ToString()));
        }
Ejemplo n.º 2
0
 public int GetItemId(object name)
 {
     return(DropDownElements.FirstOrDefault(ev => ev.Text.Trim() == name.Return(s => s.ToString(), String.Empty).Trim()).Return(ev => Convert.ToInt32(ev.Value), 0));
 }
Ejemplo n.º 3
0
 public string GetItemText(object id)
 {
     return(DropDownElements.FirstOrDefault(ev => ev.Value == id.ToString()).Return(ev => ev.Text, String.Empty));
 }
Ejemplo n.º 4
0
 public int GetItemId(object name)
 {
     return(Convert.ToInt32(DropDownElements.FirstOrDefault(ev => ev.Text.Trim() == (name ?? string.Empty).ToString().Trim())?.Value ?? "0"));
 }