I thought this would be pretty easy but I have been trying for 4 days now.
What I am trying to do is
-
Query a database
-
Place the query results into a DataSet
-
Set the Binding Source to that DataSet
-
Set the Binding Navigator's DataSource to the Binding Source
-
Set the DataGridView's DataSource to the Binding Source
However I cannot get the Binding Navigator to actually "navigate" through the returned data. The Navigator appears on my form, but the controls do not work and the row count says 1 whereas the DataGridView has around 300+ rows.
I do not know what I am doing wrong, I appreciate any help.
Here is the relevant code.
</P><FONT size=2>
<P>SqlCommand all = new SqlCommand("SELECT IndexNumber, VesselName, Active, Note, Agent, CustomerCode, ShippingAgent, CustomerPO, DeliverylabelReport, LastUpdate, EmailAddress from TableIndex", conn);
SqlDataAdapter adpt = new SqlDataAdapter(all);
DataSet ds = new DataSet();
adpt.Fill(ds, "TableIndex");
dgvCompanies.DataSource = ds.Tables[0];</P>
<P>BindingNavigator _navigator;
BindingSource _bindsrc = new BindingSource();</P>
<P>_bindsrc.Add(ds);</P>
<P>_navigator = new BindingNavigator(true);
_navigator.Parent = this;
_navigator.BindingSource = _bindsrc;
_navigator.Dock = DockStyle.Top;</P>
<P>dgvCompanies.DataSource = _bindsrc;</P>
<P mce_keep="true"> </P>
<P>