I have a Form (Compact Framework, actually) with a few fields, a date and a string, among other things. Both TextBox controls are bound to properties in a BindindSource.
The BindindSource has a DataSet as its DataSource property, and the DataMember is a table in a SQL CE database.
When I want to add a new row, I call bindingSource.AddNew(), then bindingSource.MoveLast(). The form shows the default values (as defined in the DataSet) and I can edit all the fields.
To save the form, I call bindingSource.EndEdit() and insert the values from the DataSet row into the database, using a TableAdapter method. The date makes it into the database, the string does not. Instead, the default value for the string is saved, not the value that I typed in the text box.
When I inspect the data in the DataSet table's row after calling EndEdit(), the date field is updated with the data from the form, the string is not.
Oddly enough, when I edit an existing row with the same form (without calling AddNew), the string field is updated and persisted just fine. So this only happens after calling AddNew() on the BindingSource. What am I missing? Where should I start looking?
The code is a bit too much to post here, unfortunately.
I found the issue - I had accidentially select the same column in the BindingSource for both the Tag and the Text property of the TextBox. I think what happened was that the Text was written back first, the Tag second, and because the Tag was not updated, it overwrote the modified value.
Related
I am creating a CRUD system on VB.Net, and I have converted my checkbox values to string upon adding to the database. Now, I wanted to invert the values. I want to make the checkbox state set to checked/unchecked based on the string value from the database whenever I select a row from datagrid.
Here are my checklist items from my add/create form image, I want them to appear as text on my database so I converted it to string. Now on my search form, I want those check boxes to appear checked/unchecked depending on the string value on my database whenever I selected a row. I hope this clear things up. thank you for helping out.
This is the code I am trying to work on:
CheckOne2One.Checked = Convert.ToBoolean(DataGridView1.CurrentRow.Cells("Class").Value)
I put a DataGridView named DataGridView2 on my form.
And I assigned dataSource property to a table in my DataSet, called "Account".
I set the default setting for dataGridView which allows user to modify it. And I put a Save button for user to save changed values from the grid to the database. However it doesn't work.
The code which I use in save button is :
Me.Validate()
Me.DataGridView2.Update()
Me.MyDBTableDataset.AcceptChanges()
when I debug it in the second line the there is proper value in :
DataGridView2.Rows(0).Cells(2).Value
which is user modified value in the grid. But when it executes AcceptChanges and finishes, no changes applied to my database.
Would be great if somebody can help.
Thanks
AcceptChanges does not do what you think it does. It doesn't save anything. It actually resets the DataSet so that it contains no changes to save. You can also get rid of that call to the grid's Update method as it is useless. All it does is redraw the grid onscreen.
What you actually need to do is to call Update on the same data adapter or table adapter that you originally called Fill on to retrieve the data in the first place. The Fill method executes the SelectCommand to retrieve data and the Update method executes the InsertCommand, UpdateCommand and DeleteCommand as needed to save changes back to the database.
That Update method will implicitly call AcceptChanges to indicate that the changes have been saved. It's rare that you should ever need to call AcceptChanges explicitly.
I am updating an application written in ADF 11.1.1.3. In almost all of my screens, i have ADF Tables with editable fields and every table has a row selector enabled.
I have a problem where if a user clicks in an editable field, of a table row that isnt yet selected, the field row selector appears to fire off and then the browser loses the focus on the field that the user intended to select.
Per my example screen above, the 2nd table row is currently selected. However, if i click inside any editable field in row 3 (like End Date), browser sets the focus on the field. But then the Table Row Selection listener invokes immediately after, and then takes the focus off the field i originally clicked. This happens on any editable field type.
The most annoying thing is when i update a checkbox of a table row (not selected), the value is immediately overwritten back with its original value.
Currently, the only way to get around this problem, is the user first selects the table row, then updates the field data.
Any experience with this issue? I'm thinking about a client listener or value change listener but wanted to see what your thoughts are.
Thanks!
Update 01:
I set "immediate" property to "true" for the table, still get the same results. I applied immediate=true to the parent Panel Boxes, same results.
Update 02:
The table's Iterator' and Binding's ChangeEventPolicy was set to default (none). But i set it to none anyways. Same results..
Update 03:
Removed validators, same result.
Does your selection listener still retains "#{bindings.xxx.collectionModel.makeCurrent}"? this is used to set the currently selected row as current row, if you have removed this then it means that even when you select the row by clicking on a field, the model still has previous row selected in its iterator.
I have an LOV added to my view object which updates 6 fields - done all through the LOV wizard in JDeveloper. It works perfectly fine when test running the application module - all fields update with the proper values after selecting a value from the LOV. However in my JSPX form, the only the field that gets updated is the one that the LOV is attached or is initiated on.
On my form, i only display 2 out of the 6 fields - the field which initiates the LOV and another editable field that the LOV is supposed to update. The part where this gets interesting is that the 4 other fields in my view object that i dont put in my form, are updated successfully by the LOV! But the one additional editable field that i left in my form, isnt updated.
Why is that?
I could just write a method in my View object Row Implementation class to update that editable field manually, but i feel like theres something more straight forward via declarative approach.
Thank you!
Fixed!
I needed to update two settings on my 2nd field of the form.
Removed the default bindings on the "Required" attribute and set it to "false".
Set "ShowRequired" to true
After that, I saved my changes and re-ran my application and the field updated properly!
I hope others find this helpful!
I have a column in a grid with editor as combo-box.
When the grid is loaded then all the column values get displayed properly.
The issue is, when user clicks at the column (having combobox as editor) to edit it then the column value becomes null as shown in the attached screenshot.
I understand that the value becomes null as the store of combobox has not been loaded yet.
I can not use autoLoad true due to the heavy amount of data present in the combobox store. Moreover, even if I use autoLoad:true for the store with paging in it, then that too safeguards only those values which are present in the first page and not all.
Thus, how can I maintain the value in grid column when that value is not present in the store of combobox used as editor for the column?
Could anyone guide at this?
PS: I am using ExtJS Ver 4.0.2a
I have been able to find a solution for this.
It has more to do with the version of ExtJs. If we upgrade to 4.0.7 and then use forceSelection:false for a combobox then things work fine as expected. That is, the combo-box accepts a value which doesn't exist in its store and doesn't set the current value to null.
Hope this helps someone else too looking for something similar.
I would suggest having the grid record contain both that columns value, as well as display value. If the combo store lookup is unable to find a matching value (because that combo store hasn't been loaded yet), then revert to showing the display value stored with the grid record.
You might also need to have the afteredit event on the grid update that grid records display value after that column is edited for a particular row.