Solved

Get the Value of a DataKey for a given Row in a ASP.NET Grid VIew

Posted on 2009-07-08
5
336 Views
Last Modified: 2012-05-07
Hello,
I have a Grid view GV, that have 2 of its field as DataKeyNames DK1, DK2

And i have on a click event button the attached loop.
now i guess Val is the value of the 1st DataKey DK1,
How can i get the value of DK2
thanks

Dim row As GridViewRow In GV.Rows

                 

                Dim val As Integer = Convert.ToInt32(GV.DataKeys(row.RowIndex).Value)

Open in new window

0
Comment
Question by:Nyana22
  • 3
  • 2
5 Comments
 
LVL 14

Expert Comment

by:shahprabal
ID: 24806204

Dim row As GridViewRow In GV.Rows

                 

                Dim val1 As Integer = Convert.ToInt32(GV.DataKeys(row.RowIndex).Value(0))

 Dim val2 As Integer = Convert.ToInt32(GV.DataKeys(row.RowIndex).Value(1))

Open in new window

0
 
LVL 14

Accepted Solution

by:
shahprabal earned 500 total points
ID: 24806216
Its values not value
Dim row As GridViewRow In GV.Rows

                 

                Dim val1 As Integer = Convert.ToInt32(GV.DataKeys(row.RowIndex).Values(0))

 Dim val2 As Integer = Convert.ToInt32(GV.DataKeys(row.RowIndex).Values(1))

Open in new window

0
 
LVL 14

Expert Comment

by:shahprabal
ID: 24806243
You can also use the key names instead of 0 and 1
0
 

Author Comment

by:Nyana22
ID: 24806257
i got an error :
No default member found for type 'Integer'.
didnt work for .value(0) neither .value(1),

no error for  Dim val As Integer = Convert.ToInt32(GV.DataKeys(row.RowIndex).Value)
but because of the missing parameter so the update is not working
0
 

Author Comment

by:Nyana22
ID: 24806294
sorry, was writing while you answered,
it's working with values,
thanks again
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now