ฉันมีรายการปริมาณผลิตภัณฑ์และมุมมองตาราง มุมมองตารางเชื่อมโยงกับข้อมูลบางส่วนแล้ว แต่ฉันต้องการแสดงรายการปริมาณผลิตภัณฑ์ที่คอลัมน์ที่สามของมุมมองตาราง นี่คือโค้ดเบื้องหลังเกี่ยวกับวิธีผูกข้อมูลกับมุมมองกริด:
gvProduct.DataSource = distSPUItem;
gvProduct.DataBind();
BoundField column = new BoundField();
column = new BoundField();
column.HeaderText = "Unit Quantity";
for (int index = 0; index < productQuantityList.Count; index++)
{
column.DataField = index.ToString();
}
gvProduct.Columns.Add(column);
ฉันต้องวนซ้ำรายการปริมาณผลิตภัณฑ์และแสดงผลลัพธ์ที่คอลัมน์ที่สามของมุมมองกริด อย่างไรก็ตาม คอลัมน์ดังกล่าวไม่ปรากฏขึ้น มีวิธีแก้ปัญหาอะไรบ้าง?
ขอบคุณล่วงหน้า.
ส่วนที่แก้ไข
protected void gvProduct_RowDataBound(Object sender, GridViewRowEventArgs e)
{
int unitQuantity = 0;
if(e.Row.RowType == DataControlRowType.DataRow)
{
for(int index = 0; index < productQuantityList.Count; index++)
{
unitQuantity = productQuantityList[index];
}
Label lblUnitQuantity = (Label)e.Row.FindControl("lblUnitQuantity");
lblUnitQuantity.Text = unitQuantity.ToString();
}
}
distSPUItem
และproductQuantityList
เป็นประเภทใด - person ekad   schedule 01.01.2014