RadzenListBox - is it possible to use with lists and not a database

Hello

I am not using a database, however do have many class objects, I see that when using

RadzenListBox
Data=@RoleData2 TextProperty="@RoleData2." ValueProperty="CustomerID"

I assume that
Data = the array itself
Text = is the label/text to show and value, the data behind the item

All the sample show this working with a database, it is possible to use a list if not is there a sample of how to use array data (no db)

Thank You

Hi @paulhaggo,

You can use any IEnumerable.

Thank you for your reply

I am new to IEnumerable class, I now have the values showing in the listbox, however I find that when I click 1 item, it works, but then I can not click a second, any ideas please

class Contacts : IEnumerable
{
public List ContactList { get; set; }

    public IEnumerator<Contact> GetEnumerator()
    {
        return ContactList.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return ContactList.GetEnumerator();
    }
}

class Contact
{
public string Name { get; set; }
public string LocId { get; set; }
public bool IsCompany { get; set; }
}

Contacts list = new Contacts();

public string strRandom;

var a = new Contact() { Name = "Sheffield Shop", LocId="432424", IsCompany=true };
var b = new Contact() { Name = "Manchester", LocId = "1234", IsCompany = true };
var c = new Contact() { Name = "Barnsley", LocId = "12324", IsCompany = true };

    list.ContactList = new List<Contact>();
    list.ContactList.Add(a);
    list.ContactList.Add(b);
    list.ContactList.Add(c);

<RadzenListBox @bind-Value=@strRandom Multiple="true" Data=@list TextProperty="Name" ValueProperty="LocId" Style="height:200px" />

I have worked it out and I am posting incase anyone else wants to use this without a database

Vars and Data

IEnumerable<KeyValuePair<string, Guid>> value = new List<KeyValuePair<string, Guid>>();

Dictionary<string, Guid> data = new Dictionary<string, Guid>()
    {
       {"One", Guid.Parse("11223344-5566-7788-99AA-BBCCDDEEFF00")},
       {"Two", Guid.Parse("11223344-5566-7788-99AA-BDCCDDEEFF00")},
       {"Three",Guid.Parse("11223344-1566-7788-99AA-BBCCDDEEFF00")}
    };

// And object ref on the form

<RadzenListBox @bind-Value=@value AllowFiltering="true" Data="@data" TextProperty="Key" Multiple="true" />

// Then when you want to see the data selected

// Loop "value "