referencing a key in a gridview RRS feed

  • Question

  • User-788967271 posted

    Hi all

    I want to reference a selected key value of a gridview in rowediting

    I do

    dim intc10 As Integer = s.DataKeys(e.NewEditIndex).ToString

    But I get an error because then sentence s.DataKeys(e.NewEditIndex).ToString is 'System.Web.UI.WebControls.DataKey'

    I need it in rowediting because depending on the key value I show one or another field in editing mode

    How to referece a key vaue?

    Thanks in advanced


    Sunday, July 14, 2013 9:06 AM


  • User-1716253493 posted

    For single DataKeyNames, like DataKeyNames="id", you can get it by

    Dim intc10 As Integer = GridView1.DataKeys(e.NewEditIndex).Value

    For multiple DataKeyNames, get it using

    Dim intc10 As Integer = GridView1.DataKeys(e.NewEditIndex).Values(0)
    Dim name As Integer = GridView1.DataKeys(e.NewEditIndex).Values(1)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 14, 2013 9:28 AM