I’m trying to cast an object from a DataKeyArray to a String and I get the following error:
Cannot convert type 'System.Web.UI.WebControls.DataKey' to 'string'
Is there someone to work around this problem. Here is my code that is producing the error:
int index = (int)GridView1.SelectedIndex;
HttpContext.Current.Session["Order"] = (String)GridView1.DataKeys[index];
Response.Redirect("Test.aspx");
Try:
GridView1.DataKeys[Index].Value