第一次只实例化了一个对象添加到数组里,哒咩。。。。
//model_CBF modCBF = new model_CBF();
//List<model_CBF> cbf_modelList = new List<model_CBF>();
//foreach (DataRow dr in dtSxb.Rows)
//{//model_CBF modCBF = new model_CBF();
//modCBF.YSDM = dr["YSDM"].ToString();
//modCBF.ZDDM = dr["ZDDM"].ToString();
//modCBF.BDCDYH = dr["BDCDYH"].ToString();
//modCBF.FBFBM = dr["FBFBM"].ToString();
//modCBF.HTBH = dr["合同编号"].ToString();
//modCBF.GYFS = null;
//modCBF.GYQK = null;
//cbf_modelList.Add(modCBF);//} 这种不得行!
要下面这种添加方式:记录一下
List<model_CBF> cbf_modelList = new List<model_CBF>();
foreach (DataRow dr in dtSxb.Rows)
{
cbf_modelList.Add(new model_CBF()
{
YSDM = dr["YSDM"].ToString(),
ZDDM = dr["ZDDM"].ToString(),
BDCDYH = dr["BDCDYH"].ToString(),
FBFBM = dr["FBFBM"].ToString(),
CBFBM = dr["承包方编码"].ToString(),
QDCBFS = null,
HTBH = dr["合同编号"].ToString(),
});