问题描述
这是我写的protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){stringpid=Request["pid"];List<sb>xsb=GetSbList();this.ASPxGridView1.DataSource=xsb;this.ASPxGridView1.DataBind();}}publicstringa;publicList<sb>GetSbList(){GreenInterfaceg=newGreenInterface();varxsb=newsb();varxsbList=newList<sb>();vartemp=newsb();//stringsql="selectprod_OrgName,prod_NO,prod_Name,Count,prod_Unit,prod_Price,DealTotalfromT_SubOrderswhereMainOrderID='"+pid+"'andprod_TypeName='建材'groupbyprod_OrgName,prod_NO,prod_Name,Count,prod_Unit,prod_Price,DealTotal";stringsql="selectprod_OrgName,prod_NO,prod_Name,Count,prod_Unit,prod_Price,DealTotalfromT_SubOrdersgroupbyprod_OrgName,prod_NO,prod_Name,Count,prod_Unit,prod_Price,DealTotal";DataTabledt=g.Query(sql,ConnectionStrings.DBPS).Tables[0];if(dt.Rows.Count>0){for(inti=0;i<dt.Rows.Count;i++){if(a!=dt.Rows[i]["prod_OrgName"].ToString()){temp.物料组="报价";temp.总价="800";xsbList.Add(temp);}xsb.物料组=dt.Rows[i]["prod_OrgName"].ToString();xsb.物料号=dt.Rows[i]["prod_NO"].ToString();xsb.物料名称=dt.Rows[i]["prod_Name"].ToString();xsb.数量=dt.Rows[i]["Count"].ToString();xsb.单位=dt.Rows[i]["prod_Unit"].ToString();xsb.单价=dt.Rows[i]["prod_Price"].ToString();xsb.总价=dt.Rows[i]["DealTotal"].ToString();a=dt.Rows[i]["prod_OrgName"].ToString();xsbList.Add(xsb);}}returnxsbList;}生成时出现AprimarykeyfieldspecifiedviatheKeyFieldNamepropertyisnotfoundintheunderlyingdatasource.Makesurethefieldnameisspelledcorrectly.Payattentiontothecharactercase.我想问返回的list如何绑定到ASPxGridView