Hi, I have an edit button in my grid, on click of which i want to change one grid cell of selected row to combobox.
I have written below code for the same in CellClickEvent of the grid:-
string action = e.Cell.Value.ToString();
if (action == "Edit")
{
e.Cell.Value = "Update";
UltraCombo ultraComboPanel = new UltraCombo();
ultraComboPanel.DataSource = _columnsList;
//assig combobox to the grid cell
}
But i do not know how to assign combobox to that grid cell. Is my approach correct?
Hi, I am using ValueList now and am able to show dropdown in a single cell of grid as below:-
// declare ValueList and assign items to it
private ValueList _columnList = new ValueList();
//Grid Cell Click Event
if(e.Cell.Value=="Edit")
e.Cell.Value="Update";
e.Cell.Row.Cells["ColumnName"].ValueList = _columnList;
else if (e.Cell.Value == "Update")
string selectedValue = _columnList.SelectedItem.ToString();
//make db call to update latest value
e.Cell.Value = "Edit";
BUT, here _columnList.SelectedItem is null. How to retrieve selectedText from ValueList which I have added in grid cell.
Hello sonam,
Are you sure that you are checking the right cell? If you tell what is your final goal I might be able to wrap up a sample for you.
Do you want to have one cell as a button and when you click it to make another cell a dropdown?
Hi Boris,
Yes my requirement is exactly the same as you said. I have a column 'Edit' on click of which I have to change another column of that particular selected row to Combobox And on click of update, update the latest selected value from combobox to DB and I am able to do that now by code below:-
::CellClick Event of the ulragrid
//Edit button clicked
if (e.Cell.Value.ToString() == "Edit")
//Determine the original text of the cell
_previousName = e.Cell.Row.Cells["ColumnName"].Text;
//assign combobox to the selected row cell, columnList is a ValueList defined in code
e.Cell.Row.Cells["ColumnName"].ValueList = columnList;
//Update button clicked in DB
else if e.Cell.Value.ToString() == "Update")
//setting combobox to null when Update is clicked
e.Cell.Row.Cells["ColumnName"].ValueList = null;
UltraGridRow activeRow = dgvMappedFields.ActiveRow;
//Determine newly selected value from the combobox
string newColumnName = activeRow.Cells["ColumnName"].Text;
//DB Call to update here
//Change button text to 'Edit' again
Hi,
I am glad to hear this. Please do not hesitate to contact me again if you face any other issues!