protected void RenderChat() { messages = MainClient.GetNewMessage(); messages.OrderBy(a => a.Id).ToList(); messages.Reverse(); foreach (var mes in messages) { if (mes.ToAll) { if (mes.SenderName.Equals(MainClient.player.Name)) { mes.htmlClass = "myMessage"; } messagesToAll.Add(mes); } else { if (mes.RecieverName.Equals(Player1.Name) || mes.SenderName.Equals(Player1.Name)) { if (mes.SenderName.Equals(MainClient.player.Name)) { mes.htmlClass = "myMessage"; } messagesP1.Add(mes); } else if (mes.RecieverName.Equals(Player2.Name) || mes.SenderName.Equals(Player2.Name)) { if (mes.SenderName.Equals(MainClient.player.Name)) { mes.htmlClass = "myMessage"; } messagesP2.Add(mes); } else { if (mes.SenderName.Equals(MainClient.player.Name)) { mes.htmlClass = "myMessage"; } messagesP3.Add(mes); } } } repAllChat.DataSource = messagesToAll; repAllChat.DataBind(); repP1Chat.DataSource = messagesP1; repP1Chat.DataBind(); repP2Chat.DataSource = messagesP2; repP2Chat.DataBind(); repP3Chat.DataSource = messagesP3; repP3Chat.DataBind(); }