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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

RonaldBiemansCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.