Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 22nd, 2005, 05:17 AM
Registered User
 
Join Date: Feb 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vije
Default Find Datagrid selected row

Hi,
I've dot a datagrid with a select button column. I need to find the datakey of the selected row and find that a row on the dataset and so on. Pls let me know how I can find teh datakey of the selected row of the grid.
Thank you.
-Vije
P:S Pls send me links of any walkthroughs or a tutorials u think is useful.
 
Old August 22nd, 2005, 01:18 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

The datakey is a property of the datagrid that gets or sets the property. To the the key field for the selected row, you have to know where in the grid it exists and get it like this:

'My example assumes the key value is a string

   Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles DataGrid1.ItemCommand
        If e.CommandName = "Select" Then
            Dim strKey As String
            strKey = e.Item.Cells(cell # here).Text
            Response.Write(strKey)

        End If
    End Sub

 
Old August 23rd, 2005, 08:51 AM
Registered User
 
Join Date: Feb 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vije
Default

That's great mate. Thanks a lot.
-Vije
 
Old August 23rd, 2005, 10:05 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Glad to help






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass gridview selected row msbsam ASP.NET 2.0 Basics 1 March 4th, 2008 09:17 AM
Edit selected row of datagrid Mukesh Kumar ASP.NET 1.0 and 1.1 Basics 1 April 26th, 2007 03:54 PM
Deleting selected row in ListBox YoungFools Excel VBA 1 April 19th, 2007 09:14 AM
Getting Data from selected row in gridview JoinTTT ASP.NET 2.0 Professional 3 April 17th, 2007 02:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.