Я пытаюсь создать проект ASP. NET.
Я использовал следующий код для привязки ListBox или ComboBox в Win Form
Dictionary<int, string> myPersonaDataSource; // I declare a Dictionary<int, string> ID, Name
this.myPersonaDataSource= getMyData(); // I retrive my data from the following function and put it in my Dictionary
if (dipendentiDataSource.Count != 0) // I just check if there are some values
{
initMyList();
}
private Dictionary<int, string> getMyData()
{
List<myPersona> resp = dataProvider.getPersonas(IDpersona); // I populate my List "myPersona" with values that I query from my DB
Dictionary<int, string> comboSource = new Dictionary<int, string>();
foreach (myPersona m in resp)
{
comboSource.Add(m.Name, m.ID);
}
return comboSource;
}
private void initMyList()
{
((ListBox)this.myListBox).DataSource = new BindingSource(myPersonaDataSource, null);
((ListBox)this.myListBox).DisplayMember = "Text";
((ListBox)this.myListBox).ValueMember = "Value";
}
Так что, когда дело доходит до ASP. NET свойства new BindingSource (myPersonaDataSource, null); его просто не существует, и я изо всех сил пытаюсь найти способ привязать мой ListBox с этими значениями, которые у меня уже есть!
Может кто-нибудь сказать мне, почему нет BindingSource и как я могу привязать к нему свой ListBox
Спасибо!