DataBind a list which is inside another list
<p>Below is the class file</p>

<pre><code>public class BillDetails
{
    private string chargecategory;

    [XmlAttribute("ChargeCategory")]
    public string ChargeCategory
    {
        get { return chargecategory; }
        set { chargecategory = value; }
    }

    private string customername;

    [XmlAttribute("CustomerName")]
    public string CustomerName
    {
        get { return customername; }
        set { customername = value; }
    }

    private List&lt;Details&gt; details;

    [XmlArray("Details")]
    [XmlArrayItem("details")]
   // public List&lt;Details&gt; details = new List&lt;Details&gt;();
    public List&lt;Details&gt; Details
    {
        get { return details; }
        set { details = value; }
    }
</code></pre>

<p>now in my code I need to databind only the properties which belong to List</p>

<pre><code>List&lt;BillDetails&gt; billlist = new List&lt;BillDetails&gt;();
    public int x;
    List&lt;Details&gt; newdetails = new List&lt;Details&gt;();

 public void Button1_Click(object sender, EventArgs e)
    {
        if (IsValidPost())
        {
            if (Session["BillList"] == null)
            {
                newdetails.Add(new Details() { ChargeCode = ChargeCode.Text, MaterialCode = MaterialCode.Text, GLAccount = GLAccount.Text, CostCenter = CostCenter.Text, Price = Convert.ToDecimal(Price.Text), Quantity = Convert.ToInt32(Quantity.Text), UOM = UOM.Text, Total = Convert.ToDecimal(Price.Text) * Convert.ToInt32(Quantity.Text) });
                billlist.Add(new BillDetails() { ChargeCategory = ChargeCategory.Text, Details = newdetails.ToList(), CustomerName = CustomerName.Text });
                GridView1.DataSource = newdetails *---works ...but if I give the datasource as billlist it does not ...but I want get down to newdetails from billlist.
                GridView1.DataBind();

                //Session["BillList"] = newdetails;
                Session["BillList"] = billlist;
                cleartextboxes();
                serializetoxml(billlist);

            }  
</code></pre>

<p>how do i achieve this...also in the ascx file how do I databind the columns to the properties which are in details </p>
