I have a GridView control bound to a dataset. Column A (editable) and Column B (Read Only).
When a user changes Column A, a calculation is run in the code behind and Column B changes.
It seems simple enough, but I'm having trouble getting values in my GridView to change through code. Can someone please post a simple example of how to do this?
Thank you in advance.
6 Answers, 1 is accepted
Have you tried to use an approach like this one:
myGrid.Items.EditItem(itemToEdit);
itemToEdit.ColumnA= DoChanges();
myGrid.Items.CommitEdit();
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Private Sub gvComp_CurrentCellChanged(sender As Object, e As Telerik.Windows.Controls.GridViewCurrentCellChangedEventArgs) Handles gvComp.CurrentCellChanged
Try
If e.OldCell Is Nothing Then Exit Sub
If Not e.OldCell.ParentRow Is Nothing Then
gvComp.Items.EditItem(e.OldCell.ParentRow)
' What's next ?
gvComp.CommitEdit()
End If
I would suggest you binding the ItemsSource of the GridView to the DefaultView of the DataTable instead because the DataRowView is capable of sending notifications. That way the values in the cells should be automatically updated once the change on the underlying data is done.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
There must be some way to simply update grid values in the code behind. I am a new user of your tools. Can you please show me some sample code that does this? Thank you.
I have attached the sample project suggested from my colleague in your another thread so that the whole community could benefit from it.
It illustrates a possible approach to achieve your goal.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>