Solved

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

Posted on 2009-07-08
5
337 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

825 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