一个快速的问题.. 我正在尝试创建对象列表并将其分配给网格视图。但是好像没有数据?
另外,我想在每次用户单击添加按钮时保存用户输入(只需要一个想法)。我最好的方法是什么?
List<OrderItems> orderItem = new List<OrderItems>();
protected void Page_Load(object sender, EventArgs e)
{
orderItem.Add(new OrderItems("Test1", "Test2"));
orderItem.Add(new OrderItems("Test1", "Test2"));
orderItem.Add(new OrderItems("Test1", "Test2"));
orderItem.Add(new OrderItems("Test1", "Test2"));
orderItem.Add(new OrderItems("Test1", "Test2"));
}
protected void btnAddItem_Click(object sender, EventArgs e)
{
// Producing an error of no data
grdTest.DataSource = orderItem;
grdTest.DataBind();
}
这是我的课:
public class OrderItems
{
private string prodId;
private string qty;
public OrderItems()
{
}
public OrderItems(string prodId, string quantity)
{
this.prodId = prodId;
this.qty = quantity;
}
public string productId
{
get
{
return productId;
}
}
public string quantity
{
get
{
return quantity;
}
}
}
谢谢