HI All,

1) I open up a dataset (declared at the module level)
2) I get the data with the .FILL using the DataAdapter
3) I update a DataGrid RecordSource property to the DataSource
4) I update the DataBindings of a Text box to one of those fields.

Now, the data loads into the datagrid and the text box just fine.
When I move around in the datagrid, it changes the value in the text
box.

Now, how do I change the current record using code? I've tried using
the:

me.bindingcontext(dsCustomer, "dtCustomer").position

Modifing this values does not modify the control on the screen and
changing the record position on the screen does not change the
bindingcontext.position value.

Any help is appreciated.

Dave.

Dataset and Bindings by Patrick

Patrick
Mon Sep 15 15:14:09 CDT 2003

Dave,
That should work (assuming you are using the .ToString()
method).

lblRecord.Text = me.bindingcontext
(dsCustomer, "dtCustomer").position.ToString(). The
position method returns an int. One of my projects uses
the very same. Good luck

>-----Original Message-----
>HI All,
>
>1) I open up a dataset (declared at the module level)
>2) I get the data with the .FILL using the DataAdapter
>3) I update a DataGrid RecordSource property to the
DataSource
>4) I update the DataBindings of a Text box to one of
those fields.
>
>Now, the data loads into the datagrid and the text box
just fine.
>When I move around in the datagrid, it changes the value
in the text
>box.
>
>Now, how do I change the current record using code?
I've tried using
>the:
>
>me.bindingcontext(dsCustomer, "dtCustomer").position
>
>Modifing this values does not modify the control on the
screen and
>changing the record position on the screen does not
change the
>bindingcontext.position value.
>
>Any help is appreciated.
>
>Dave.
>.
>

Re: Dataset and Bindings by Brad

Brad
Tue Sep 16 07:19:03 CDT 2003

This is a multi-part message in MIME format.

------=_NextPart_000_00FA_01C37C2B.30AA2200
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Dave,

This is what I use in one of my programs to advance one record:
Me.BindingContext(dataset, "TableName").Position +=3D 1

I then use ... +-1 to go back one and so on.

Hope this helps.

Brad Allison

<dave@here.ca> wrote in message =
news:0b0cmvg2moco7k45f8b5vd9f80vdnop60a@4ax.com...
> HI All,
>=20
> 1) I open up a dataset (declared at the module level)
> 2) I get the data with the .FILL using the DataAdapter
> 3) I update a DataGrid RecordSource property to the DataSource
> 4) I update the DataBindings of a Text box to one of those fields.
>=20
> Now, the data loads into the datagrid and the text box just fine.
> When I move around in the datagrid, it changes the value in the text
> box.
>=20
> Now, how do I change the current record using code? I've tried using
> the:
>=20
> me.bindingcontext(dsCustomer, "dtCustomer").position
>=20
> Modifing this values does not modify the control on the screen and
> changing the record position on the screen does not change the
> bindingcontext.position value.
>=20
> Any help is appreciated.
>=20
> Dave.
------=_NextPart_000_00FA_01C37C2B.30AA2200
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1226" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Dave,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>This is what I use in one of my =
programs to advance=20
one record:</FONT></DIV>
<DIV>
<P><FONT face=3DArial size=3D2>Me.BindingContext(dataset, =
"TableName").Position +=3D=20
1</FONT></P>
<P><FONT face=3DArial size=3D2>I then use&nbsp; ... +-1 to go back one =
and so=20
on.</FONT></P>
<P><FONT face=3DArial size=3D2>Hope this helps.</FONT></P>
<P><FONT face=3DArial size=3D2>Brad Allison</FONT></P></DIV>
<DIV><FONT face=3DArial size=3D2>&lt;</FONT><A =
href=3D"mailto:dave@here.ca"><FONT=20
face=3DArial size=3D2>dave@here.ca</FONT></A><FONT face=3DArial =
size=3D2>&gt; wrote in=20
message </FONT><A =
href=3D"news:0b0cmvg2moco7k45f8b5vd9f80vdnop60a@4ax.com"><FONT=20
face=3DArial=20
size=3D2>news:0b0cmvg2moco7k45f8b5vd9f80vdnop60a@4ax.com</FONT></A><FONT =

face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>&gt; =
HI All,<BR>&gt;=20
<BR>&gt; 1)&nbsp; I open up a dataset (declared at the module =
level)<BR>&gt;=20
2)&nbsp; I get the data with the .FILL using the DataAdapter<BR>&gt; =
3)&nbsp; I=20
update a DataGrid RecordSource property to the DataSource<BR>&gt; =
4)&nbsp; I=20
update the DataBindings of a Text box to one of those fields.<BR>&gt; =
<BR>&gt;=20
Now, the data loads into the datagrid and the text box just =
fine.<BR>&gt; When I=20
move around in the datagrid, it changes the value in the text<BR>&gt;=20
box.<BR>&gt; <BR>&gt; Now, how do I change the current record using =
code?&nbsp;=20
I've tried using<BR>&gt; the:<BR>&gt; <BR>&gt; =
me.bindingcontext(dsCustomer,=20
"dtCustomer").position<BR>&gt; <BR>&gt; Modifing this values does not =
modify the=20
control on the screen and<BR>&gt; changing the record position on the =
screen=20
does not change the<BR>&gt; bindingcontext.position value.<BR>&gt; =
<BR>&gt; Any=20
help is appreciated.<BR>&gt; <BR>&gt; Dave.</FONT></BODY></HTML>

------=_NextPart_000_00FA_01C37C2B.30AA2200--


Re: Dataset and Bindings by dave

dave
Wed Sep 17 06:58:33 CDT 2003

Thanks Brad and Patrick,

I figured it out. Before, I had:

FormLoad
========
mconnCust = New SqlConnection(....)
mdaCust = New SqlDataAdapter("Select * from Customers", mconnCust)
mdaCust.Fill(mdsCust, "dtCustomer")
DataGrid1.DataSource = mdsCust.Tables("dtCustomer")
tCustomerID.DataBindings.Add("Text", mdsCust.Tables("dtCustomer"),_
"CustomerID")

Now this would populate the datagrid and the textbox. Changing the
position of the datagrid would change the value in the textbox. When
I did a:

MsgBox(Me.BindingContext(mdsCust.Tables("dtCustomer")).Position

It would always return 0, regardless of where I was on the datagrid.
Changing this value would NOT update the position in the datagrid or
the textbox.

I then added a databindings to the datagrid,

FormLoad
========
mconnCust = New SqlConnection(....)
mdaCust = New SqlDataAdapter("Select * from Customers", mconnCust)
mdaCust.Fill(mdsCust, "dtCustomer")
DataGrid1.DataSource = mdsCust.Tables("dtCustomer")
tCustomerID.DataBindings.Add("Text", mdsCust.Tables("dtCustomer"),_
"CustomerID")
DataGrid1.DataBindings.Add("", mdsCust,_
mdsCust.Tables("dtCustomer").TableName)

It now works like a charm.


On Tue, 16 Sep 2003 08:19:03 -0400, "Brad Allison"
<ballison@ukcdogs.com> wrote:

>Dave,
>
>This is what I use in one of my programs to advance one record:
>Me.BindingContext(dataset, "TableName").Position += 1
>
>I then use ... +-1 to go back one and so on.
>
>Hope this helps.
>
>Brad Allison
>
><dave@here.ca> wrote in message news:0b0cmvg2moco7k45f8b5vd9f80vdnop60a@4ax.com...
>> HI All,
>>
>> 1) I open up a dataset (declared at the module level)
>> 2) I get the data with the .FILL using the DataAdapter
>> 3) I update a DataGrid RecordSource property to the DataSource
>> 4) I update the DataBindings of a Text box to one of those fields.
>>
>> Now, the data loads into the datagrid and the text box just fine.
>> When I move around in the datagrid, it changes the value in the text
>> box.
>>
>> Now, how do I change the current record using code? I've tried using
>> the:
>>
>> me.bindingcontext(dsCustomer, "dtCustomer").position
>>
>> Modifing this values does not modify the control on the screen and
>> changing the record position on the screen does not change the
>> bindingcontext.position value.
>>
>> Any help is appreciated.
>>
>> Dave.