I have a code to create a GridView. It displays fine except for the SenderDetails
column. I need to create an item template for this.
The Message
and Date
DataFields come from a class called Chat
and they display fine in the grid. But SenderDetails
is called from another class in the chat class:
public class Chat : BaseResultSet
{
public string Message { get; set; }
public DateTime? SentDate { get; set; }
public ChatUserDetails SenderDetails { get; set; }
}
The ChatUserDetails
class is:
public class ChatUserDetails : BaseDisplaySet
{
public string UserName { get; set; }
public string CompanyName { get; set; }
public bool Connected { get; set; }
}
So instead of displaying the username it displays baseClasses.Chat.ChatUserDetails
in the SenderDetails
column.
I need to display the UserName in the BuildChatsGrid()
.
GridView code:
public static GridView BuildChatsGrid()
{
GridView NewDg = new GridView();
NewDg.Columns.Add(new BoundField { DataField = "Message", HeaderText = "Note" });
NewDg.Columns.Add(new BoundField { DataField = "SenderDetails", HeaderText = "Entered By" }); //need item template
NewDg.Columns.Add(new BoundField { DataField = "SentDate", HeaderText = "Date", DataFormatString = "{0:dd/MM/yyyy}" });
}
So how do I add an item template or templatefield to call SenderDetails
?