GridView的列是动态生成的,所以GridView要显示的东西也是变的,怎么在cs页控制GridView的显示内容
(怎么从cs页给aspx页的GridView传值(代码写到cs页))
------最佳解决方案--------------------------------------------------------
前台:
<asp:GridView ID="gv" runat="server">
<Columns>
</Columns>
</asp:GridView>
后台:
DataRow row;
DataTable dtTpQty = new DataTable();
dtTpQty.Columns.Add("ID");
dtTpQty.Columns.Add("type");
dtTpQty.Columns.Add("qty");
row = dtTpQty.NewRow();
row["ID"] = "0001";
row["type"] = "0";
row["qty"] = "2500";
dtTpQty.Rows.Add(row);
row = dtTpQty.NewRow();
row["ID"] = "0001";
row["type"] = "1";
row["qty"] = "3100";
dtTpQty.Rows.Add(row);
row = dtTpQty.NewRow();
row["ID"] = "0001";
row["type"] = "2";
row["qty"] = "2600";
dtTpQty.Rows.Add(row);
row = dtTpQty.NewRow();
row["ID"] = "0001";
row["type"] = "3";
row["qty"] = "1500";
dtTpQty.Rows.Add(row);
row = dtTpQty.NewRow();
row["ID"] = "0002";
row["type"] = "0";
row["qty"] = "1100";
dtTpQty.Rows.Add(row);
row = dtTpQty.NewRow();
row["ID"] = "0002";
row["type"] = "1";
row["qty"] = "4200";
dtTpQty.Rows.Add(row);
row = dtTpQty.NewRow();
row["ID"] = "0002";
row["type"] = "2";
row["qty"] = "3200";
dtTpQty.Rows.Add(row);
row = dtTpQty.NewRow();
row["ID"] = "0002";