Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-07-08
5
Medium Priority
?
345 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

772 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