I have created a GridView to display a parent-child dataset. I have created and assigned all columns in code. This code works fine. I am able to add data and successfully update the database.
I need to capture changes to a GridViewComboBoxColumn. I want to detect when the ComboBox selection has changed and set date values for other fields in the row. I have included the event code below. It mostly works. The values come back to the grid in the correct place, but as soon as I click into another cell, the values disappear.
I have also tried a solution similar to the code below using rgv.CurrentRow.Cells["From"].Value instead of CellElement. The behaviour and results are similar but not quite successful. I have also tried enclosing the cell updates inside of rgv.GridElement.BeginUpdate() and rgv.GridElement.EndUpdate(); That didn't work either. .
This is a pretty typical thing to do in Microsoft .NET controls so I am a bit mystified as to why this appears to be so difficult with advanced controls. I am certain it is user error. but I just don't know where to look at this point. .I would appreciate it immensely if someone could point me in the right direction.
I am new to Telerik. I have figured out quite a bit in the last few days, but now I am under the gun to deliver.
Thanks in advance
John
private void rgv_ValueChanged(object sender, EventArgs e)
{
if (sender is RadComboBoxEditor)
{
RadComboBoxEditor editor = this.rgv.ActiveEditor as RadComboBoxEditor;
if (editor != null)
switch(editor.Value.ToString())
{
case "Before" :
rgv.CurrentRow.Cells["From"].CellElement.Text = DateTime.MinValue.ToString();
rgv.CurrentRow.Cells["From"].CellElement.Enabled = false;
rgv.CurrentRow.Cells["To"].CellElement.Enabled = true;
break;
case "After" :
rgv.CurrentRow.Cells["To"].CellElement.Text = DateTime.MaxValue.ToString();
rgv.CurrentRow.Cells["From"].CellElement.Enabled = true;
rgv.CurrentRow.Cells["To"].CellElement.Enabled = false;
break;
case "Range" :
rgv.CurrentRow.Cells["From"].CellElement.Text = DateTime.Now.ToString();
rgv.CurrentRow.Cells["To"].CellElement.Text = DateTime.Now.ToString();
rgv.CurrentRow.Cells["From"].CellElement.Enabled = true;
rgv.CurrentRow.Cells["To"].CellElement.Enabled = true;
break;
default :
break;
}
}
I need to capture changes to a GridViewComboBoxColumn. I want to detect when the ComboBox selection has changed and set date values for other fields in the row. I have included the event code below. It mostly works. The values come back to the grid in the correct place, but as soon as I click into another cell, the values disappear.
I have also tried a solution similar to the code below using rgv.CurrentRow.Cells["From"].Value instead of CellElement. The behaviour and results are similar but not quite successful. I have also tried enclosing the cell updates inside of rgv.GridElement.BeginUpdate() and rgv.GridElement.EndUpdate(); That didn't work either. .
This is a pretty typical thing to do in Microsoft .NET controls so I am a bit mystified as to why this appears to be so difficult with advanced controls. I am certain it is user error. but I just don't know where to look at this point. .I would appreciate it immensely if someone could point me in the right direction.
I am new to Telerik. I have figured out quite a bit in the last few days, but now I am under the gun to deliver.
Thanks in advance
John
private void rgv_ValueChanged(object sender, EventArgs e)
{
if (sender is RadComboBoxEditor)
{
RadComboBoxEditor editor = this.rgv.ActiveEditor as RadComboBoxEditor;
if (editor != null)
switch(editor.Value.ToString())
{
case "Before" :
rgv.CurrentRow.Cells["From"].CellElement.Text = DateTime.MinValue.ToString();
rgv.CurrentRow.Cells["From"].CellElement.Enabled = false;
rgv.CurrentRow.Cells["To"].CellElement.Enabled = true;
break;
case "After" :
rgv.CurrentRow.Cells["To"].CellElement.Text = DateTime.MaxValue.ToString();
rgv.CurrentRow.Cells["From"].CellElement.Enabled = true;
rgv.CurrentRow.Cells["To"].CellElement.Enabled = false;
break;
case "Range" :
rgv.CurrentRow.Cells["From"].CellElement.Text = DateTime.Now.ToString();
rgv.CurrentRow.Cells["To"].CellElement.Text = DateTime.Now.ToString();
rgv.CurrentRow.Cells["From"].CellElement.Enabled = true;
rgv.CurrentRow.Cells["To"].CellElement.Enabled = true;
break;
default :
break;
}
}