I can't get my child band to work properly with my data structure. Here is my data
public class MessageHelper { public int MessageId { get; set; } public string Message { get; set; } public DateTime Date { get; set; } public List<AttachmentHelper> Attachments { get; set; } public MessageHelper() { Attachments = new List<AttachmentHelper>(); } } public class AttachmentHelper { public int AttachmentId { get; set; } public int MessageId { get; set; } public DateTime AttachmentDate { get; set; } public string FileName { get; set; } }I create 2 rows in a function that returns a List<MessageHelper>List<MessageHelper> messages = new List<MessageHelper>(); messages.Add(new MessageHelper() { MessageId = 1, Date = DateTime.Now, Message = "This is a fake message.", Attachments = new List<AttachmentHelper>() { new AttachmentHelper() { AttachmentId = 1, MessageId = 1, FileName = "MyTextFile.txt", AttachmentDate = DateTime.Now }, new AttachmentHelper() { AttachmentId = 2, MessageId = 1, FileName = "MyTextFile2.txt", AttachmentDate = DateTime.Now } } }); messages.Add(new MessageHelper() { MessageId = 2, Date = DateTime.Now, Message = "This is another fake message.", Attachments = new List<AttachmentHelper>() { new AttachmentHelper() { AttachmentId = 3, MessageId = 2, FileName = "Test.doc", AttachmentDate = DateTime.Now }, new AttachmentHelper() { AttachmentId = 4, MessageId = 2, FileName = "Test2.doc", AttachmentDate = DateTime.Now }, new AttachmentHelper() { AttachmentId = 5, MessageId = 2, FileName = "Test3.doc", AttachmentDate = DateTime.Now } } }); that collection is assigned to the datasourcehere is the grid code <ig:WebHierarchicalDataGrid ID="grid" runat="server" AutoGenerateColumns="false" AutoGenerateBands="false" InitialDataBindDepth="0" DataKeyFields="MessageId" Height="300" Width="800px"> <AjaxIndicator Enabled="False" /> <Columns> <ig:BoundDataField DataFieldName="MessageId" Key="MessageId" Header-Text="ID" Width="30px" /> <ig:BoundDataField DataFieldName="Message" Key="Message" Header-Text="Message" /> <ig:BoundDataField DataFieldName="Date" Key="Date" Header-Text="Date" Width="100px" /> </Columns> <Bands> <ig:Band Key="Attachments" AutoGenerateColumns="false" DataKeyFields="AttachmentId" > <Columns> <ig:BoundDataField DataFieldName="AttachmentId" Key="AttachmentId" Header-Text="Attachment ID" /> <ig:BoundDataField DataFieldName="FileName" Key="FileName" Header-Text="Attached File" /> <ig:BoundDataField DataFieldName="AttachmentDate" Key="AttachmentDate" Header-Text="Last Modified" /> </Columns> </ig:Band> </Bands> </ig:WebHierarchicalDataGrid>If I set AutoGenerateBands to false, it works fine. Why is my band column definition not working?Any help would be appreciated.
List<MessageHelper> messages = new List<MessageHelper>(); messages.Add(new MessageHelper() { MessageId = 1, Date = DateTime.Now, Message = "This is a fake message.", Attachments = new List<AttachmentHelper>() { new AttachmentHelper() { AttachmentId = 1, MessageId = 1, FileName = "MyTextFile.txt", AttachmentDate = DateTime.Now }, new AttachmentHelper() { AttachmentId = 2, MessageId = 1, FileName = "MyTextFile2.txt", AttachmentDate = DateTime.Now } } }); messages.Add(new MessageHelper() { MessageId = 2, Date = DateTime.Now, Message = "This is another fake message.", Attachments = new List<AttachmentHelper>() { new AttachmentHelper() { AttachmentId = 3, MessageId = 2, FileName = "Test.doc", AttachmentDate = DateTime.Now }, new AttachmentHelper() { AttachmentId = 4, MessageId = 2, FileName = "Test2.doc", AttachmentDate = DateTime.Now }, new AttachmentHelper() { AttachmentId = 5, MessageId = 2, FileName = "Test3.doc", AttachmentDate = DateTime.Now } } });
<ig:WebHierarchicalDataGrid ID="grid" runat="server" AutoGenerateColumns="false" AutoGenerateBands="false" InitialDataBindDepth="0" DataKeyFields="MessageId" Height="300" Width="800px"> <AjaxIndicator Enabled="False" /> <Columns> <ig:BoundDataField DataFieldName="MessageId" Key="MessageId" Header-Text="ID" Width="30px" /> <ig:BoundDataField DataFieldName="Message" Key="Message" Header-Text="Message" /> <ig:BoundDataField DataFieldName="Date" Key="Date" Header-Text="Date" Width="100px" /> </Columns> <Bands> <ig:Band Key="Attachments" AutoGenerateColumns="false" DataKeyFields="AttachmentId" > <Columns> <ig:BoundDataField DataFieldName="AttachmentId" Key="AttachmentId" Header-Text="Attachment ID" /> <ig:BoundDataField DataFieldName="FileName" Key="FileName" Header-Text="Attached File" /> <ig:BoundDataField DataFieldName="AttachmentDate" Key="AttachmentDate" Header-Text="Last Modified" /> </Columns> </ig:Band> </Bands> </ig:WebHierarchicalDataGrid>If I set AutoGenerateBands to false, it works fine. Why is my band column definition not working?Any help would be appreciated.
Figured this one out. My childband was missing the DataMember="Attachments" property. I was actually going to leave AutoGenerateBands=true and in the InitializeRow event of the grid, adjust my columns layout there (and it worked, but was a hack). While searching for a different error I came across this post
http://community.infragistics.com/forums/t/35449.aspx
Which helped.