[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Datagrid and Textbox binding

Posted on 2004-10-27
Medium Priority
Last Modified: 2011-09-20

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 ;-)
Question by:kGenius
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4

Expert Comment

ID: 12420121

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?

LVL 25

Expert Comment

ID: 12420603
If you have binded the textboxes to the same datasource as the grid it should happen automaticaly without any extra coding
LVL 25

Expert Comment

ID: 12420616
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 25

Accepted Solution

RonaldBiemans earned 500 total points
ID: 12420653
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

Author Comment

ID: 12432565

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 :)
LVL 25

Expert Comment

ID: 12432602
Hi KGenius,

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

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question