DataBind列在另一个列表中的列表

时间:2011-03-14 21:19:18

标签: c#

以下是课程文件

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

的属性
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文件中如何将列数据绑定到详细属性

1 个答案:

答案 0 :(得分:0)

我会 假设 DataMember = "Details";会这样做(但我个人不会使用webforms数据绑定,所以如果失败我会道歉。)< / p>

相关问题