Solved

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

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

12 Experts available now in Live!

Get 1:1 Help Now