Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 22nd, 2005, 05:17 AM
Registered User
 
Join Date: Feb 2005
Location: , , United Kingdom.
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.
  #2 (permalink)  
Old August 22nd, 2005, 01:18 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
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

  #3 (permalink)  
Old August 23rd, 2005, 08:51 AM
Registered User
 
Join Date: Feb 2005
Location: , , United Kingdom.
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
  #4 (permalink)  
Old August 23rd, 2005, 10:05 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Glad to help

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:02 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.