I am new to .net. I am trying to populate a listbox with the following code. what am I doing wrong? The compiler complaigns about the last line saying "cannot convert a non deligate type"
private void popList()
{
var context = new AWDEntities();
{
var query = from c in context.COMMITTEES
where c.COMMITTEE_ID == 5
select new { c.COMMITTEE_HOUSE, c.COMMITTEE_MEMBERSHIP, c.COMMITTEE_HEARING_AGENDAS };
var cust = query.First();
ListBox1.Text = cust.ToString;
};
}
}
}
.NET ProgrammingASP.NET
Last Comment
vcurtis
8/22/2022 - Mon
Ess Kay
here is a basic way to populate a listbox
List<string> MyList = new List<string>();
MyList.Add("HELLO");
MyList.Add("WORLD");
Ess Kay
try this
private void popList()
{
var context = new AWDEntities();
{
var query = from c in context.COMMITTEES
where c.COMMITTEE_ID == 5
select new { c.COMMITTEE_HOUSE, c.COMMITTEE_MEMBERSHIP, c.COMMITTEE_HEARING_AGENDAS };
var cust = query.First(); ListBox1.Add(cust.ToString);
}
}
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
List<string> MyList = new List<string>();
MyList.Add("HELLO");
MyList.Add("WORLD");