Datagrid and Textbox binding

Hi,

I've created a custom control that reads data from a database and put the result in a dataset. I've binded the datagrid to the dataset.
Then I read the dataset (the columns, columnnames and types) to create dynamicly textboxes and labels as much as there are columns. I bind the textboxes to the dataset.
Everything is loading fine. When I run the application, I get my custom control with the datagrid and the textboxes. In the textboxes I can see the first row of the dataset.
Now I want to scroll through the dataset by selecting a new row in the datagrid. The textboxes must show the selected row.
How can I do that?

Thanx in advance
kGenius (ahum)
PS sorry for the poor grammar ;-)
LVL 7
kGeniusAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
RonaldBiemansConnect With a Mentor Commented:
to explain a little

datagrid1.datasource = ds.tables(0)
TextBox1.DataBindings.Add("Text", ds.tables(0), "yourcolumnname")

will scroll

datagrid1.datasource = ds.tables(0)
dim dv as dataview = ds.tables(0).defaultview
TextBox1.DataBindings.Add("Text", dv, "yourcolumnname")

will not scroll

although the seem to be bound to the same datasource, they aren't
0
 
jameskearneyCommented:

handle the datagrid rowchanged or rowselected event (cant remember which/what event specifically it has), and then in that event do

textbox.text = ctype( currentRow.Item("columnName"), String)

thats just off of the top of my head,

is that any help at all?

james
0
 
RonaldBiemansCommented:
If you have binded the textboxes to the same datasource as the grid it should happen automaticaly without any extra coding
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
RonaldBiemansCommented:
oeps pressed submit too soon,


If you have binded the textboxes to the same datasource as the grid it should happen automaticaly without any extra coding.

So if the data in the textboxes  does not scroll automatically with the grid then you have done something wrong,
If you could post some code maybe we can see where you went wrong
0
 
kGeniusAuthor Commented:
Thanks,

I've had this code: textbox1.DataBindings.Add("Text", ds.Tables(0).defaultview, "columnname")

I've removed the .DefaultVieuw and everything is fine now !
The table must be binded not a dataview, I see !

thanks again,
kGenius (a bit more :)
0
 
RonaldBiemansCommented:
Hi KGenius,

You can bind your textboxes to the dataview but then your datagrid should also be binded to the dataview
0
All Courses

From novice to tech pro — start learning today.