private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { if(ValidateForBindingNewPalletLocation()){ DataRow dr = gridView1.GetFocusedDataRow(); //for validation Double writeoff = 0; Double reLocate = 0; try { if (dr["WriteOff"] != DBNull.Value) { writeoff = Double.Parse(dr["WriteOff"].ToString()); } if (dr["ReLocate"] != DBNull.Value) { reLocate = Double.Parse(dr["ReLocate"].ToString()); } } catch (Exception exc) { } // bind data set to the repository item try { if (dr["WriteOff"] != DBNull.Value && writeoff>0) { int palletid = int.Parse(dr["PalletID"].ToString()); PalletLocation pl = new PalletLocation(); newpalletlocationrepositoryItemGridLookUpEdit.DataSource = pl.GetPalletLocationsOnTheSameStore(palletid); } else if (dr["ReLocate"] != DBNull.Value & reLocate>0) { Item itms = new Item(); itms.GetItemByPrimaryKey(Convert.ToInt32(dr["ItemID"])); newpalletlocationrepositoryItemGridLookUpEdit.DataSource = PalletLocation.GetAllFreeForIntheSameStore(Convert.ToInt32(dr["ItemID"]), int.Parse(dr["PalletID"].ToString())); } else { newpalletlocationrepositoryItemGridLookUpEdit.DataSource = null; } } catch (Exception except) { } } }