find 2 datakeys in cowcommand

Posted on 2012-09-13
Last Modified: 2012-10-14
I have this code that finds the a datakey in a gridview

The problem is that I have 2 datakeys in the gridview and I can't get the 2nd one..

The below code just accesses the first datakey but how do I access the 2nd?

Protected Sub GridView2_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView2.RowCommand
        Dim currentCommand As String = e.CommandName
        Dim currentRowIndex As Integer = Int32.Parse(e.CommandArgument.ToString())
        Dim EmailAdd As String = GridView2.DataKeys(currentRowIndex).Value

Open in new window

Question by:edjones1
    LVL 18

    Accepted Solution

    Try this :
    Dim gvrow As GridViewRow
    Dim value1 As String = gvUserInfo.DataKeys(gvrow.RowIndex).Values(0).ToString()
    Dim value2 As String = gvUserInfo.DataKeys(gvrow.RowIndex).Values(1).ToString()
    Dim value3 As String = gvUserInfo.DataKeys(gvrow.RowIndex).Values(2).ToString()

    Open in new window

    Convert C#to vb


    Author Closing Comment

    Worked Perfectly, thanks

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    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…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    746 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

    19 Experts available now in Live!

    Get 1:1 Help Now