Aspxgridview编辑表单级联DropDown

时间:2016-11-11 09:40:53

标签: c# devexpress

在ASPxGridView中我有GridViewDataComboBoxColumn,其中有EditForm。  text和value字段都只是字符串。如果我从第一个下拉选择值意味着它没有在第二个下拉列表中获取值它返回空值我不知道我应该在哪里更改代码。

我从第一个组合框中得不到任何价值。 我没有收到任何错误。

亲切检查我的代码。

[C#]
 protected void grdMaterialsFlow_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e)
        {
 if (e.Column.FieldName == "SKU")
                {
                    DataSet ds = new DataSet();
                    FacilityId = ((DevExpress.Web.ASPxCallbackPanel)this.Page.Master.FindControl("cmpMastePageCallBackPanel")).FindControl("TitleContent").FindControl("cmbFacility") as DevExpress.Web.ASPxComboBox;
                    string val = FacilityId == null ? String.Empty : FacilityId.SelectedItem == null ? String.Empty : Convert.ToString(FacilityId.SelectedItem.Value);
                    ds = DBMethod.SelectSKUname(FacilityId.SelectedItem.Value.ToString());
                     ASPxComboBox cmb = e.Editor as ASPxComboBox;
                    SMgmt.PropddsUserRole = ds;
                    cmb.DataSource = ds;
                    cmb.ValueField = "SKU";
                    //cmb.ValueType = typeof(int);
                    cmb.TextField = "SKU";
                    cmb.DataBindItems();
                }
 if (e.Column.FieldName == "UOM")
                {
                    var combo = (ASPxComboBox)e.Editor;
                    combo.Callback += new CallbackEventHandlerBase(cmbUOM_OnCallback);
                    var grid = e.Column.Grid;
                    if (!combo.IsCallback)
                    {
                        string SKU = "";
                        if (!grid.IsNewRowEditing)
                            SKU = (String)grid.GetRowValues(e.VisibleIndex, "SKU");
                        FillUOMCombo(combo, SKU);
                    }
                }
}
 protected void FillUOMCombo(ASPxComboBox cmb, String SKU)
        {
            FacilityId = ((DevExpress.Web.ASPxCallbackPanel)this.Page.Master.FindControl("cmpMastePageCallBackPanel")).FindControl("TitleContent").FindControl("cmbFacility") as DevExpress.Web.ASPxComboBox;
            string val = FacilityId == null ? String.Empty : FacilityId.SelectedItem == null ? String.Empty : Convert.ToString(FacilityId.SelectedItem.Value);
            DataSet ds = DBMethod.SelectUOMname((SKU), val);
            cmb.DataSource = ds;
            cmb.ValueField = "UOM";
            cmb.ValueType = typeof(string);
            cmb.TextField = "UOM";
            cmb.DataBindItems();
        }
        void cmbUOM_OnCallback(object source, CallbackEventArgsBase e)
        {     

            var UOM = -1;
            Int32.TryParse(e.Parameter, out UOM);
            FillUOMCombo(source as ASPxComboBox, UOM.ToString());

        }

1 个答案:

答案 0 :(得分:0)

     SharedPreferences userDetails = getApplicationContext()
.getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);

此方法用于获取组合框中的文本