I have my sql statement and my reader to add each item to the stubs in Message and my stubs in message data
This is message data
public class MessageData { public MessageData() { } public int id { get; set; } public string Subject { get; set; } public string Body { get; set;} public int File_Id {get; set;} public bool ForPublic {get;set;} public bool ForPrivate {get;set;} public bool ForKKOnly {get;set;} public int UserID {get;set;} public int PriorityID {get;set;} }
A list contains none, one or many individual items.
It is like a shelf with numbers of books on it - you don't read the shelf, you take one book away and read that.
You take an item out of the list and process that item.
Haver Ramirez
my mistake;
md.AddRange(m.GetEditThread(ID));//or List<Data.MessageData> md = new List<Data.MessageData>(m.GetEditThread(ID));
?
What has that got to do with your original error when you attempted to cast a list of items to an individual item
Haver Ramirez
you are using a List, you must use items, not the LIST in self
Data.Message m = new Data.Message();List<Data.MessageData> md = new List<Data.MessageData>(m.GetEditThread(ID)); if (md.Count > 0){lblPostID.Text = Convert.ToString(md[0].id);radtxtBody.Text = md[0].Body;radtxtSubject.Text = md[0].Subject;}
that means the suggested solution didnt work - I was doing that all day long - and to be honest Andy I dont need analogies or a life lesson in coding or someone with the mentality that they are a guru - II come here for actual help - Crashman was kiind enough to offer - you are not
IMHO
R
AndyAinscow
Before you criticise you should read my comment.
I told you EXACTLY why your original code failed AND what to do to correct it.
Open in new window