I’ve had a ton of places I needed this type of control. If you need to embed a dynamically populated dropdown or combobox in a grid here is a pretty simple ways to do it. This builds on using the dynamic query adapter to pull query results (in this case the BAQ query called “DB_AvailDims”) for use in a dropdown list.
I’ve added UD01 as a child to the QuoteDtl table using the wizard in this Post. I’ve added tab and ultragrid which uses the wizard created edvUD01 view as the datasource for the ultragrid called “eugFeatures”.
Of note, I used the valuelist property from the ActiveRow.Cell. It’s not as fancy as the other drop downs but fit my needs in this instance. I originally had this code posted on the Load_Form action but since it uses the “dum” variable (aka shortchar02) from each row, I had to add it to the AfterRowActivate so it would call the query as each row was activated.
//-------------------------- Set Row Value for value list query ------------------------
private void eugFeatures_AfterRowActivate(object sender, System.EventArgs args){
string dum = this.eugFeatures.ActiveRow.Cells["ShortChar02"].Value.ToString();
DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("DB_AvailDims");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("InputUOM", dum , "nvarchar",false, Guid.NewGuid(),"A");
dqa.ExecuteByID("DB_AvailDims",qeds);
//Build Drop Down
ValueList vl = new ValueList();
if (dqa.QueryResults.Tables["Results"].Rows.Count > 0)
{
foreach (DataRow dr in dqa.QueryResults.Tables["Results"].Rows)
{
vl.ValueListItems.Add(dr["UOMConvOut_UOMCode"]);
}
}
this.eugFeatures.ActiveRow.Cells["ShortChar03"].ValueList = vl;
}