I am trying to skip the rows of my gridview and get the data key value of each row, and then execute some code to run sql queries. How can I get the data key value of each row in a variable? I am getting an error right now:
a value of type system.web.ui.webcontrols.datakey cannot be converted to an integer.
Here is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load For Each row As GridViewRow In GridView1.Rows Dim therowindex As Integer = row.RowIndex Dim theid As Integer = GridView1.DataKeys([therowindex]) 'execute some more code running queries using the data key value. Next End Sub
source share