zqf213 2015-11-18 07:37 采纳率: 0%
浏览 1462
已结题

关于dev gridview 主键的问题

前台代码 Width="90%" SkinID="skDev" CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx">



<%#Container.ItemIndex+1 %>

/dx:GridViewDataTextColumn

/dx:GridViewDataTextColumn

/dx:GridViewDataTextColumn

/dx:GridViewDataTextColumn

/dx:GridViewDataTextColumn

/dx:GridViewDataTextColumn

/dx:GridViewDataTextColumn

/dx:GridViewDataTextColumn

/dx:GridViewDataTextColumn

                </Columns>

后台:
public partial class BuildingMaterials : System.Web.UI.Page
{

    public string pid
    {
        get
        {
            return Request["pid"];
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string pid = Request["pid"];
            List<sb> xsb = GetSbList();
            this.ASPxGridView1.DataSource = xsb;
            this.ASPxGridView1.DataBind();

        }
    }


    public string a;


    public List<sb> GetSbList()
    {

        GreenInterface g = new GreenInterface();
        var xsb = new sb();
        var ctx = new Linq.DBPSDataContext();
        var ctx1 = new Linq.DBQSDataContext();

        var xsbList = new List<sb>();
        var temp = new sb();


        string sql = "select prod_OrgName,prod_NO,prod_Name,Count,prod_Unit,prod_Price,DealTotal from T_SubOrders group by prod_OrgName,prod_NO,prod_Name,Count,prod_Unit,prod_Price,DealTotal";
        DataTable dt = g.Query(sql,ConnectionStrings.DBPS).Tables[0];
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (a != dt.Rows[i]["prod_OrgName"].ToString())
                {
                    string b = dt.Rows[i]["prod_OrgName"].ToString();
                    temp.ID = i;
                    temp.单位 = "报价";
                    temp.单价 = "800";

                    xsbList.Add(temp);
                }
                xsb.ID = i;
                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);
            }
        }

        return xsbList;

    }


    public class sb
    {
        public int ID;

        public string 物料组;

        public string 物料号;

        public string 物料名称;

        public string 数量;

        public string 单位;

        public string 单价;

        public string 总价;

        public string 增减项;

    }



            一直显示这个错误:其他信息: A primary key field specified via the KeyFieldName property is not found in the underlying data source. Make sure the field name is spelled correctly. Pay attention to the character case.

            我主键也设置了   为什么还显示这个  
  • 写回答

1条回答 默认 最新

  • exception92 2015-11-19 03:10
    关注

    A primary key field specified via the KeyFieldName property is not found in the underlying data source. Make sure the field name is spelled correctly. Pay attention to the character case.

    错误的大概意思是 你没有通过 “KeyFieldName” 属性来 设置主键,并且确定主键 拼写正确。

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器