2011-03-14 56 views
0

下面是類文件數據綁定列表,這是內部的另一個列表

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<Details> details; 

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

現在在我的代碼,我需要數據綁定只屬於列出

List<BillDetails> billlist = new List<BillDetails>(); 
    public int x; 
    List<Details> newdetails = new List<Details>(); 

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); 

      } 

屬性我如何做到這一點...在ascx文件中,我如何將列數據綁定到詳細的​​屬性

+0

有人會幫助我,因爲這對我來說是迫切的。 – Janet 2011-03-14 21:28:13

回答

0

我會假設DataMember = "Details";會做到這一點(但我不親自使用webforms數據綁定,所以我道歉,如果失敗)。

相關問題