Unable to bind a column which in a list within a list

Mar 15, 2011
Reaction score
:congrats:Hello ,

I have the following code:

public class abc
public string customername { get; set; }
public List<def> DEF { get; set; }

public class def
public string materialcode { get; set; }

on page load

protected void Page_Load(object sender, EventArgs e)
List<abc> test1 = new List<abc>();
List<def> test2 = new List<def>();

test2.Add(new def() {materialcode="something" });
test1.Add(new abc(){customername="anything", DEF=test2});
GridView1.DataSource = test1;

and in the ascx file

<asp:GridView ID="GridView1" runat="server">

<asp:TemplateField HeaderText="Charge Code">
<asp:Label ID="lblchargecode" runat="server" Text='<%#((def)Eval("DEF"))[0].materialcode %>'></asp:Label>


I am getting an error message stating that def is not a member , if i am missing an assembly reference.

Please help me bind it to the gridview. Its very urgent

Thanks all.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question