/// <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())); }
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)); }
public string GetItemText(object id) { return(DropDownElements.FirstOrDefault(ev => ev.Value == id.ToString()).Return(ev => ev.Text, String.Empty)); }
public int GetItemId(object name) { return(Convert.ToInt32(DropDownElements.FirstOrDefault(ev => ev.Text.Trim() == (name ?? string.Empty).ToString().Trim())?.Value ?? "0")); }