Visual C# and ADO.NET: Combo Box Data Binding: "In the Properties window, set the properties as follows:
DataSource: dsPersons1.Genders
DisplayMember: Gender
ValueMember: GenderID
DataBindings -> SelectedValue: dsPersons1 - Persons.GenderID"
Thursday, March 22, 2007
ADO.NET musings (A control does not work directly with a DataTable . When you bind a control, a DataView is created and the controls interacts with..
Greg Robinson's Blog : AddNew vs. NewRow: "AddNew vs. NewRow
These 2 methods have confused me for a while. I assumed under the covers calls to AddNew created a new DataRow, marked as Detached, just like a call to NewRow does.
A control does not work directly with a DataTable . When you bind a control, a DataView is created and the controls interacts with the datatable through that view.
So, calls to AddNew are interacting with the DataView, not the DataTable. AddNew creates a new DataRowView
Public Overridable Function AddNew() As DataRowView
So, you will be working with a DataRowView, not a DataRow, on calls to AddNew."
These 2 methods have confused me for a while. I assumed under the covers calls to AddNew created a new DataRow, marked as Detached, just like a call to NewRow does.
A control does not work directly with a DataTable . When you bind a control, a DataView is created and the controls interacts with the datatable through that view.
So, calls to AddNew are interacting with the DataView, not the DataTable. AddNew creates a new DataRowView
Public Overridable Function AddNew() As DataRowView
So, you will be working with a DataRowView, not a DataRow, on calls to AddNew."
Wednesday, March 21, 2007
Currencymanager and finding underlying record i DB
Currencymanager and finding underlying record i DB: "* If you need to current underlying DataRow, then yes you can get it from
the CurrencyManager, but the 'underlying row' is always a DataRowView (even
when bound to DataTable), from the DataRowView you can get the DataRow; eg:
' using the same DataSource as the one you used for binding
Dim cm As CurrencyManager = DirectCast(BindingContext(DvSpare),
CurrencyManager)
' if you want to be safe, you could also use:
Dim cm As CurrencyManager = DirectCast(BindingContext(dgSpare.DataSource,
dgSpare.DataMember), CurrencyManager)
' then you can get the current DataRowView:
Dim drv As DataRowView = DirectCast(cm.Current, DataRowView)
' from the DataRowView you can get the DataRow:
Dim dr as DataRow = drv.Row
* On the other hand, if you bind to a DataView, then the DataGrid indexes
are the same as the DataView, so you could simply use:
Dim drv As DataRowView = DvSpare(DgSpare.CurrentRowIndex)
Dim dr As DataRow = drv.Row
"
the CurrencyManager, but the 'underlying row' is always a DataRowView (even
when bound to DataTable), from the DataRowView you can get the DataRow; eg:
' using the same DataSource as the one you used for binding
Dim cm As CurrencyManager = DirectCast(BindingContext(DvSpare),
CurrencyManager)
' if you want to be safe, you could also use:
Dim cm As CurrencyManager = DirectCast(BindingContext(dgSpare.DataSource,
dgSpare.DataMember), CurrencyManager)
' then you can get the current DataRowView:
Dim drv As DataRowView = DirectCast(cm.Current, DataRowView)
' from the DataRowView you can get the DataRow:
Dim dr as DataRow = drv.Row
* On the other hand, if you bind to a DataView, then the DataGrid indexes
are the same as the DataView, so you could simply use:
Dim drv As DataRowView = DvSpare(DgSpare.CurrentRowIndex)
Dim dr As DataRow = drv.Row
"
Tuesday, March 20, 2007
modifying a textbox bound to datasource - rowstate always says UNCHANGED - .NET VB
modifying a textbox bound to datasource - rowstate always says UNCHANGED - .NET VB: "Re: modifying a textbox bound to datasource - rowstate always says UNCHANGED
John
One of the most asked questions in these newsgroups.
For databinding there has to be a change of a control others than a button.
Therefore you have to push the data down by hand when you click a button.
(To do it efficient you can do it before the update command)
BindingContext(ds.Tables(0)).EndCurrentEdit()
I hope this helps,
Cor"
John
One of the most asked questions in these newsgroups.
For databinding there has to be a change of a control others than a button.
Therefore you have to push the data down by hand when you click a button.
(To do it efficient you can do it before the update command)
BindingContext(ds.Tables(0)).EndCurrentEdit()
I hope this helps,
Cor"
Monday, March 19, 2007
.NET Questions - Designer can't be shown - classes can't be designed
.NET Questions - Designer can't be shown - classes can't be designed: "I had a similar problem but I was inheriting from a generic base class... This was the kind of error I was getting:
'The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: DerivedControl --- The base class 'GenericControlBase' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.'"
----
solution is to close all forms
'The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: DerivedControl --- The base class 'GenericControlBase' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.'"
----
solution is to close all forms
Subscribe to:
Comments (Atom)