我在ViewState中有一个DataTable,同样的DataTable用于数据绑定Gridview,它有模板列和计算字段
现在,当用户按下按钮时,所选行(复选框)的数据表中的所有记录都应复制到另一个数据表
public void GeneratePO1()
{
// get the datatable from Viewstate
DataTable myDS = (DataTable)ViewState["BomData"];
//create a new datatable to store New Selected Items
DataTable dt = new DataTable();
//clone the schme of the Orginal Datatble to new one
dt = myDS.Clone();
//Loop through each gridviewrows to find the Rows where checkbox column is checked
foreach (GridViewRow di in tbl_bom.Rows)
{
CheckBox chkBx = (CheckBox)di.FindControl("chk_select");
if (chkBx != null && chkBx.Checked)
{
//get the uniqueID of that row
int skudetpk = int.Parse((di.FindControl("lbl_skudetpk") as Label).Text);
//create a new datarow for dt
DataRow dr = dt.NewRow();
//query the orginal datatable and put it in new data row
dr = myDS.Select("SkuDet_pk=" + skudetpk + "");//Error occurs here
//add the datarow to datatable
dt.Rows.Add(dr);
}
}
Session["ItemforPO"] = dt;
}
我收到以下错误信息
无法将类型'System.Data.DataRow []'隐式转换为'System.Data.DataRow'
答案 0 :(得分:0)
根据Jon Skeet的建议。我已经添加了.Single()tio数据表,然后我没有添加行我导入了行。这解决了我的问题
import matplotlib.pyplot as plt
import random
x = 0
y = 0
for a in range(0,9):
i = random.randint(0,9)
j = random.randint(0,9)
x = x + i
y = y + i
plt.scatter(x,y)
plt.show()