Velocity Reviews

Velocity Reviews (
-   ASP .Net (
-   -   How to get values from selected item in a gridview (

Julia B 10-08-2008 02:08 PM

How to get values from selected item in a gridview
Hi all, just as I'd got the hang of datagrids in 1.1 they change to gridviews
and everything is done differentley...... I'm really stuck so help would be

I've got a gridview which has a select command. When the user clicks the
select command I want the data from the selected row to be pasted into some
controls/fields I have, the problem is that I can't seem to be able to get
the data, here's one of the variations i've tried:

Private Sub dgDepts_RowCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewCommandEventArgs ) Handles dgDepts.RowCommand
If e.CommandName.Equals("Select") Then
'populate the department edit fields with the data from the
selected record
Me.tbDept.Text = Me.dgDepts.SelectedRow.Cells(0).Text
End If
End Sub

I get an error message at Me.dgDepts.SelectedRow.Cells(0).Text as it's
showing as nothing.

I've also tried me.dgDepts.sSlectedDataKey.Item(0).ToString but get the same
message (although I'm not sure I really understand this new datakey lark).

I've searched high and low to get examples of how to do this and have found
lots but nothing that matches what I need to do.

Any clues greatly appreciated.

All times are GMT. The time now is 01:47 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.