Unable to get the id of the selected item in the ultra combo'
i have a win grid, wherein there are several columns containing 3 combo boxes and other text editor columns.
The valueList for each combo is a class that gets it data from the specific columns in the db.
When i use grid.activerow.cells["ColumnName"].value, i am getting a null value.
Have any reason why this is the case?
nakash said:When i use grid.activerow.cells["ColumnName"].value, i am getting a null value.
So.. just to be clear.. you are saying that you selected a value from the list and you can see the text in the cell, but the Value of the cell is still returning null?
What event are you using the check the Value? My guess is that you are probably using an event that is firing when the cell's text has been update, but the value has not yet been committed to the data source, such as the CellChange event.
Yes @ mike, the even that i am using is afterRowUpdate. The code below should provide some clarity, cbo.SelectedRow is null. I first click on the combo box, select an item and the text property is showing in th combo box. I would like to know how is it that cbo.SelectedRow is null.
id1 = TourCombo.GetId(grdCombo, "TourId").ToString();
public static int GetId(UltraCombo cbo, string columnName)
{
UltraGridRow row;
UltraGridCell cell;
int id = 0;
row = cbo.SelectedRow;
if (row != null)
cell = row.Cells[columnName];
if (cell != null)
id = (int)cell.Value;
}
return id;
Hi,
You can't use the SelectedRow of the Combo. The grid isn't actually using the Combo control you specified, it simply uses an editor provided by the combo.
Remember, the combo services the entire column and each cell in the column has a different value. So the combo has no context to determine a selected row, since it doesn't know what grid cell you would want.
You need to use properties and event of the grid, not the Combo. If you are using AfterRowUpdate, then all you have to do is get the value of the grid cell, not a cell from the SelectedRow of the Combo.
Both myself and a co-worker realized that two ways in which we could actually get the id of the value selected one of which is id1 = grdTourPricingPriceDetails.ActiveRow.Cells["TourName"].Value.ToString();