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

Discussion in '.NET' started by janaki, Mar 15, 2011.

  1. janaki

    janaki

    Joined:
    Mar 15, 2011
    Messages:
    1
    :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;
    GridView1.DataBind();
    }

    and in the ascx file


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

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

    </Columns>
    </asp:GridView>

    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.
    janaki, Mar 15, 2011
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dmitry Korolyov [MVP]

    Dynamically bind dropdown list etc in template column

    Dmitry Korolyov [MVP], Oct 16, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    5,892
    Craig Deelsnyder
    Oct 17, 2003
  2. Jim Hammond
    Replies:
    1
    Views:
    3,613
    bruce barker
    Nov 26, 2003
  3. mr2_93
    Replies:
    1
    Views:
    3,593
    mr2_93
    Oct 2, 2005
  4. vishnu
    Replies:
    1
    Views:
    1,203
    Patrick.O.Ige
    Mar 25, 2006
  5. XHengDF@gmail.com
    Replies:
    0
    Views:
    590
    XHengDF@gmail.com
    May 29, 2007
Loading...

Share This Page