I am making a chat function on my site.
When somebody enter any text to it, I want it to show all messeges from when ever he entered the chat until now. It works fine and all...
var query = from es in gr.chats
where es.timestamps > date
orderby es.timestamps ascending
List<chat> list = new List<chat>();
foreach (chat chat1 in query)
for (int i = 0; i < list.Count; i++)
lbChat.Items.Add("[" + list[i].timestamps + "] " + list[i].personID.ToString() + ": " + list[i].besked);
this.ListBox1.Items.Add(new ListItem("Hello", "1")); this.ListBox1.SelectedIndex = this.ListBox1.Items.Count - 1;
The first line simply adds an item. The second one sets its SelectedIndex which determines which item in the ListBox item's list should be selected.