Scenario:
I have a list of line items for checks to be 'approved' by the CEO. He can take one of three actions. He can approve it, he can explicitly deny it, or he can choose to do nothing on it at this point.
Implementation:
I have a hierarchical GridView that properly shows everything I need. I have a single column there with 3 options " ", "approve", "deny", declared as below:
It is then added to the MasterGridViewTemplate.
All of this is completely fine. I am able to capture 'ValueChanged' when it is changed and by testing the active editor I can determine that it's a combobox being changed... again, all of this is working and there is no problem.
Problem:
However, I have a button that I want to use to approve ALL items in the grid. So, in the button click, I loop through the rows, and then reference the proper cell, but I cannot figure out how to set the selectedIndex. I can just set a 'value' which doesn't really do what I want... here's one of the code attempts I've made:
That code will literally set the Value to 0 or 1. I have tried casting the row.Cells["Approved"] as a GridViewComboBoxColum or GridComboBoxCellElement and in both cases it did not work.
That doesn't work because you cannot convert type 'Telerik.WinControls.UI.GridViewCellInfo' to 'System.Windows.Forms.ComboBox'.
Surely there is an easy way to do this?
I have a list of line items for checks to be 'approved' by the CEO. He can take one of three actions. He can approve it, he can explicitly deny it, or he can choose to do nothing on it at this point.
Implementation:
I have a hierarchical GridView that properly shows everything I need. I have a single column there with 3 options " ", "approve", "deny", declared as below:
GridViewComboBoxColumn colApproved = new GridViewComboBoxColumn(); |
colApproved.FieldAlias = "Approved"; |
colApproved.FieldName = "Approved"; |
colApproved.HeaderText = "Approved"; |
colApproved.DataSource = new string[] { " ", "Approve", "Deny" }; |
It is then added to the MasterGridViewTemplate.
All of this is completely fine. I am able to capture 'ValueChanged' when it is changed and by testing the active editor I can determine that it's a combobox being changed... again, all of this is working and there is no problem.
Problem:
However, I have a button that I want to use to approve ALL items in the grid. So, in the button click, I loop through the rows, and then reference the proper cell, but I cannot figure out how to set the selectedIndex. I can just set a 'value' which doesn't really do what I want... here's one of the code attempts I've made:
private void btnApproveAll_Click(object sender, EventArgs e) |
{ |
foreach(GridViewDataRowInfo row in this.radGridView1.MasterGridViewTemplate.Rows) |
{ |
if (((Button)sender).Text == "Approve All") |
{ |
row.Cells["Approved"].Value = 1; |
} |
else |
{ |
row.Cells["Approved"].Value = 0; |
} |
} |
if (((Button)sender).Text == "Approve All" ) |
{ |
((Button)sender).Text = "UnApprove All" ; |
} |
else |
{ |
((Button)sender).Text = "Approve All"; |
} |
} |
That code will literally set the Value to 0 or 1. I have tried casting the row.Cells["Approved"] as a GridViewComboBoxColum or GridComboBoxCellElement and in both cases it did not work.
((ComboBox)row.Cells["Approved"]).SelectedIndex = 1; |
That doesn't work because you cannot convert type 'Telerik.WinControls.UI.GridViewCellInfo' to 'System.Windows.Forms.ComboBox'.
Surely there is an easy way to do this?