I have a DataGrid and a DataForm. I'm assigning data to the DataForm with the currently selected Item in the datagrid individually as DataForm.CurrentItem. This means that I do not have any Next/Previous button on the DataForm and the user can switch to any row in the DataGrid.
My problem is that although I have set the property AutoCommit="True" on the DataForm, if the user edits something and clicks on another record in the DataGrid, it crashes.
How can I force it to save the DataForm when the user moves away from the form?
I got this working but I'm not sure whether this is correct. On SelectionChanged event of datagrid I added the following:
DataForm.CommitEdit();
and it stopped crashing and giving me the error. If anyone else has a better solution please do let me know.
Related
How can I transfer selected rows from datagridview to another datagridview in another form? I'm having trouble with this.
You should be able to do that in in one of gridview event handlers. I would use
RowCommand Occurs when a button is clicked in a GridView control.
But you can do it any other event that meets your needs. Both the Gridview must be on same page so you can access them from code behind. You can access any control on the page using code behind, including GridView. You should be able to add contents/remove contents as needed. Make sure you issue databaind on both gridviews so they are rendered fresh after the changes. So basically you need code behind :)
I am trying to create a wrapper to replace the sheridan datagrid actvex control with a datagridview.
The sheridan datagrid control supports an event which fires just before the user is going to add a row to the grid called BeforeInsert.
Does anyone know of an equivalent event in the datagridview control or or some other code I could write which produces the same effect?
I'm having a look at all the events here, I don't see one for Adding or Inserting a row, just Added. Although there's one for Deleting and Deleted strangely enough. I won't pretend to know why. To your question, how exactly will users be adding rows? You could try playing around with the "AllowUserToAddRowsChanged" event and change that property programatically when the user wants to add a row.
Anyone has a clue what might go wrong? This behaviour happens after I make some changes in the grid that associates properties to the items in the listview, select a different item, at save prompt I cancel and revert the selection, now if I try to select the already selected item event fires. I dont know why.
I do change the selection programatically when I revert the selection if I cancel at the save promt.
I managed to reproduce this problem. It's resolved if you set the MultiSelect property to false. However, if you need multiple selections, another solution will be needed.
A UserControl 'wrapper' around the ListView that handles the SelectedItemChanged event and only responds if the item is different is an option.
I have added a button in datarepeater. If clicked once, it executes code and Button.text should change to Yes. Clicked again, it executes the opposite code and button.text should change to No. Codes are being executed (I am using flag variable) but Button.text is not changing.
How to change this text. I am simply trying Button.text="Yes" but probably I need to give some reference of the row no. too. How to do it?
Please advise.
Thanks
Furqan
Please check this question:
Handle Button Click in WinForm DataRepeater C# Power Pack
Also: the CurrentItem property has a property named Controls that allows you to access its child controls like this: CurrentItem.Controls["OKButton"]
I have a strange problem with a DataGridView I'm using which is bound to a table in VB.net
I've added a checkbox column to allow a user to tick a bunch of rows that I can then loop through and save off to a different table. All the checkboxes are enabled by default. So it's really a case of unchecking the rows which aren't required.
However, the DataGridView re-enables any checkbox that I click after I click on a checkbox in another row. So in effect, only one row can be unchecked at a time.
I'm sure I'm probably missing something obvious here?
EDIT: I forgot to mention this is a Windows form, not an ASP.net application.
I think this is what is happening. Please check if you have checked IsPostback while binding the datagridview. I think the click event of the checkbox is initiating a postback and it is rebinding itself.
HTH
I think the grid is refreshing and then redrawing the default values...
I got it working in the end, although I'm not sure exactly how. It must have been some property that I tweaked in the grid