I am using .net 2005.
I have created a GridView with one column having a command button.
The DataAdapter, DataSource, DataSet were created in code, not with wizards.
When the command button is clicked, I can't figure out the syntax for retreiving the value from the first cell in the selected row.
Can someone help?

thanks,
earlofroberts

This should work with a Windows Desktop App; strText = Me.dgvGrid.SelectedCells.Item(0).Value.ToString & ""

select the 1st cell of rows

dim i as integer
i = datagrid.CurrentRowIndex()

text = Trim(datagrid.Item(i, 0))

emurf,
thanks, but it's a web app.

jx_man,
thanks, but it's a gridview not a datagrid, so it doesn't have the item property.

dim string1 as string

string1 = gridview1.rows(row#).cells(cell#).tostring

now, here is the kicker. the first row is row "0"
the first column/cell is "0"

it goes against intuition of using 1...

if you still need help estenson1 at gmail

best,
eric

add after .cells(cell#).text.tostring

dim string1 as string

string1 = gridview1.rows(row#).cells(cell#).tostring

now, here is the kicker. the first row is row "0"
the first column/cell is "0"

it goes against intuition of using 1...

if you still need help estenson1 at gmail

best,
eric

**********************************************
Thanks a lot , it worked in my case.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.