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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Cell Value from Datagrid

Status
Not open for further replies.

byrne1

Programmer
Aug 7, 2001
415
US
I have a datagrid that is bound to a dataset and it has 45 records showing (4 columns per record). But when I try to get one of the values it returns a blank string!!! Why?????

I'm using the following code to get the value:

strValue = DataGrid1.Items(10).Cells(1).Text

No matter what number I use for the item (save anything greater than 45) it returns a blank string.
 
As long as the cell is visible, you actually have a control in there as well as the cell text itself. So you have to do something like this

strValue = CType(DataGrid1.Items(10).Cells(1).Controls(1), Label).Text

This is if the control being displayed is a label (the defualt, unless you've set something else up in a template)

Hope this helps Mark [openup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top