devexpress中ASPxGridView控件初始化赋值

写在ASPxGridView中OnCellEditorInitialize="ASPxGridView_progoods_CellEditorInitialize"  事件中:

 //(新增时)初始化赋值

        protected void ASPxGridView_progoods_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs e)

        {

            //初始化授权商品名称

            if (e.Column.FieldName == "GOODS_ID")

            {

                DataTable dt = bll.GetList_goods(PEOID.ToString()).Tables[0];

                ASPxComboBox cmb1 = e.Editor as ASPxComboBox;

                for (int i = 0; i < dt.Rows.Count; i++)

                {

                    cmb1.Items.Add(dt.Rows[i]["GOODSNAME"].ToString(), dt.Rows[i]["GOODS_ID"].ToString());

                }

            }

            //新增时给是否有效字段初始化赋值为‘是’(默认)

            if (ASPxGridView_progoods.IsNewRowEditing == true && e.Column.FieldName == "ISVALID")

            {

                ASPxComboBox cmb2 = e.Editor as ASPxComboBox;

                cmb2.SelectedIndex = 1;

            }

        }

原文地址:https://www.cnblogs.com/dfxyw/p/5080103.html