This is my list definition
public class EventsList
{
public int EventID { get; set; }
public string EventName { get; set; }
}
This is C# code
string strCurrentUser = CommonWeb.GetLoginUser();
EventsClass EventObj = new EventsClass();
DataSet ds;
List< EventsList> eventList = new List<EventsList>();
EventsList eventobj = new EventsList();
ds=EventObj.GetEvents(strCurrentUser);
I have a drop down in which it shoould display the EventName alone. How could i achieve this??
Your question isn’t clear, but it sounds like it might be as simple as using the indexer of
List<T>, which makes accessing an element look like array access:For a more general
IEnumerable<string>you can use theElementAtextension method: