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.