VINOTH KUMAR VINOTH KUMAR - 23 days ago 9
C# Question

Aspxgridview edit form Cascading DropDown

In ASPxGridView I have GridViewDataComboBoxColumn where in EditForm is there.
Both the text and value fields are string only. If i select the value from 1st drop down means it not gettting value in second dropdrop down it return null value where i dont know where should i changee the code.

I am not get any value from 1st combo box .
I am not getting any error.

Kind Check my Code.

[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());

}

Answer
void cmbUOM_OnCallback(object source, CallbackEventArgsBase e)
        {
            ASPxComboBox combo = (ASPxComboBox)source;
            FillUOMCombo(combo, e.Parameter);
        }

This method is used to get the Text in the Combo Box