Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display a field from a data grid to a textbox 1

Status
Not open for further replies.

graydon123

Technical User
Feb 25, 2004
10
US
Hello,

I have a datagrid and would like to enable the user to select a cell from the datagrid, which would then populate a textbox/label with data from the selected field. I am having a heck of a time trying to grab data from a desired field in a datagrid. I can display the selectedrowindex, I just cannot display any other data from datagrid.

Thanks to all who can help me out!

 
graydon123,

I am doing the exact thing in my program. Whether this is the best way to do it or not I don't know, but it works.

In the datagrid_click event I have the following code:

dr = dsData.Tables("Name").Rows(dg.CurrentRowIndex)
txtLName.Text = dr("LastName")
txtFName.Text = dr("FirstName")
txtCustID.text = dr("ID")
txtBalance.text = dr("Balance")

This allows me to pick and choose only the cells that I want to have displayed. Granted, this is on a datagrid that is read only so that only changes can be made within the textboxes and only to the cells that I will allow access to.

Hope this helps,

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top