Solved

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

Posted on 2009-07-08
5
339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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